Skip to content

Commit 865a9eb

Browse files
authored
Fix error returns (prometheus#356)
Include `err` in some error returns to allow `error.Is()` to work. Signed-off-by: Ben Kochie <superq@gmail.com>
1 parent ab65999 commit 865a9eb

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

proc_psi.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ type PSIStats struct {
5959
func (fs FS) PSIStatsForResource(resource string) (PSIStats, error) {
6060
data, err := util.ReadFileNoStat(fs.proc.Path(fmt.Sprintf("%s/%s", "pressure", resource)))
6161
if err != nil {
62-
return PSIStats{}, fmt.Errorf("psi_stats: unavailable for %s", resource)
62+
return PSIStats{}, fmt.Errorf("psi_stats: unavailable for %s, err: %s", resource, err)
6363
}
6464

6565
return parsePSIStats(resource, bytes.NewReader(data))

sysfs/class_powercap.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package sysfs
1717

1818
import (
19-
"errors"
19+
"fmt"
2020
"io/ioutil"
2121
"path/filepath"
2222
"strconv"
@@ -41,8 +41,7 @@ func GetRaplZones(fs FS) ([]RaplZone, error) {
4141

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

4847
var zones []RaplZone

0 commit comments

Comments
 (0)