Skip to content

Commit

Permalink
Fix error returns (prometheus#356)
Browse files Browse the repository at this point in the history
Include `err` in some error returns to allow `error.Is()` to work.

Signed-off-by: Ben Kochie <[email protected]>
  • Loading branch information
SuperQ authored Feb 9, 2021
1 parent 8cf1637 commit d335eb2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion proc_psi.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type PSIStats struct {
func (fs FS) PSIStatsForResource(resource string) (PSIStats, error) {
data, err := util.ReadFileNoStat(fs.proc.Path(fmt.Sprintf("%s/%s", "pressure", resource)))
if err != nil {
return PSIStats{}, fmt.Errorf("psi_stats: unavailable for %s", resource)
return PSIStats{}, fmt.Errorf("psi_stats: unavailable for %s, err: %s", resource, err)
}

return parsePSIStats(resource, bytes.NewReader(data))
Expand Down
5 changes: 2 additions & 3 deletions sysfs/class_powercap.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package sysfs

import (
"errors"
"fmt"
"io/ioutil"
"path/filepath"
"strconv"
Expand All @@ -41,8 +41,7 @@ func GetRaplZones(fs FS) ([]RaplZone, error) {

files, err := ioutil.ReadDir(raplDir)
if err != nil {
return nil, errors.New(
"no sysfs powercap / RAPL power metrics files found")
return nil, fmt.Errorf("unable to read class/powercap: %s", err)
}

var zones []RaplZone
Expand Down

0 comments on commit d335eb2

Please sign in to comment.