Skip to content

Commit

Permalink
unify linux/windows error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Mar 22, 2024
1 parent a89ce9b commit bc7a52f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/snclient/check_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,14 @@ func (l *CheckFiles) Check(_ context.Context, _ *Agent, check *CheckData, _ []Ar

// check for errors here, maybe the file would have been filtered out anyway
if err != nil {
entry["_error"] = strings.TrimPrefix(err.Error(), "lstat ")
switch {
case os.IsNotExist(err):
entry["_error"] = fmt.Sprintf("%s: no such file or directory", path)
case os.IsPermission(err):
entry["_error"] = fmt.Sprintf("%s: no such file or directory", path)
default:
entry["_error"] = fmt.Sprintf("%s: %s", path, err.Error())
}

return nil
}
Expand Down

0 comments on commit bc7a52f

Please sign in to comment.