refactored error handling in LoadKeys()

This commit is contained in:
Haris Khan
2024-09-09 20:07:43 -04:00
parent d23cb52f2c
commit 3a99966c42

View File

@ -71,15 +71,15 @@ func LoadKeys(r string) (I2PKeys, error) {
if err != nil {
return I2PKeys{}, err
}
if exists {
if !exists {
return I2PKeys{}, fmt.Errorf("file does not exist: %s", r)
}
fi, err := os.Open(r)
if err != nil {
return I2PKeys{}, err
return I2PKeys{}, fmt.Errorf("error opening file: %w", err)
}
defer fi.Close()
return LoadKeysIncompat(fi)
}
return I2PKeys{}, err
}
// store keys in non standard format