Skip to content

Commit

Permalink
Fix up powersupplyclass error
Browse files Browse the repository at this point in the history
Switch to go `%w` error verb and errors.Is().

Signed-off-by: Ben Kochie <[email protected]>
  • Loading branch information
SuperQ committed Jun 15, 2020
1 parent 35bfe45 commit 39c6174
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions collector/powersupplyclass.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package collector

import (
"errors"
"fmt"
"os"
"regexp"
Expand Down Expand Up @@ -55,7 +56,7 @@ func NewPowerSupplyClassCollector(logger log.Logger) (Collector, error) {
func (c *powerSupplyClassCollector) Update(ch chan<- prometheus.Metric) error {
powerSupplyClass, err := getPowerSupplyClassInfo(c.ignoredPattern)
if err != nil {
if os.IsNotExist(err) {
if errors.Is(err, os.ErrNotExist) {
return ErrNoData
}
return fmt.Errorf("could not get power_supply class info: %s", err)
Expand Down Expand Up @@ -188,7 +189,7 @@ func getPowerSupplyClassInfo(ignore *regexp.Regexp) (sysfs.PowerSupplyClass, err
powerSupplyClass, err := fs.PowerSupplyClass()

if err != nil {
return powerSupplyClass, fmt.Errorf("error obtaining power_supply class info: %s", err)
return powerSupplyClass, fmt.Errorf("error obtaining power_supply class info: %w", err)
}

for device := range powerSupplyClass {
Expand Down

0 comments on commit 39c6174

Please sign in to comment.