better error handling

This commit is contained in:
2024-12-19 10:55:39 +01:00
parent 1b9ec48396
commit 97837076a3
6 changed files with 29 additions and 29 deletions

View File

@@ -52,7 +52,7 @@ func (attr *DbAttr) GetFileValue() error {
} else {
filehandle, err := os.OpenFile(attr.File, os.O_RDONLY, 0600)
if err != nil {
return err
return fmt.Errorf("failed to open file %s: %w", attr.File, err)
}
fd = filehandle
@@ -62,7 +62,7 @@ func (attr *DbAttr) GetFileValue() error {
// read from file or stdin pipe
data, err := io.ReadAll(fd)
if err != nil {
return err
return fmt.Errorf("failed to read from pipe: %w", err)
}
// poor man's text file test