Fix up powersupplyclass error

Switch to go `%w` error verb and errors.Is().

Signed-off-by: Ben Kochie <superq@gmail.com>
This commit is contained in:
Ben Kochie 2020-06-15 08:00:35 +02:00 committed by Johannes 'fish' Ziemke
parent 35bfe455df
commit 64ba27e7d6
1 changed files with 3 additions and 2 deletions

View File

@ -17,6 +17,7 @@
package collector
import (
"errors"
"fmt"
"os"
"regexp"
@ -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)
@ -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 {