From 64ba27e7d616f4507c7ec67adcd8f17850e5cfbc Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Mon, 15 Jun 2020 08:00:35 +0200 Subject: [PATCH] Fix up powersupplyclass error Switch to go `%w` error verb and errors.Is(). Signed-off-by: Ben Kochie --- collector/powersupplyclass.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/collector/powersupplyclass.go b/collector/powersupplyclass.go index 368235ea..309b08c2 100644 --- a/collector/powersupplyclass.go +++ b/collector/powersupplyclass.go @@ -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 {