From 662831e25287c90723a467f4ef434e779707aea9 Mon Sep 17 00:00:00 2001 From: Yorick Smilda Date: Tue, 31 Jan 2023 11:05:57 +0100 Subject: [PATCH] Use `%w` on errors --- internal/model/end-device-frequency-plan.go | 22 ++++++++++----------- internal/model/gateway-frequency-plan.go | 14 ++++++------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/internal/model/end-device-frequency-plan.go b/internal/model/end-device-frequency-plan.go index 3f98366..efd3705 100644 --- a/internal/model/end-device-frequency-plan.go +++ b/internal/model/end-device-frequency-plan.go @@ -35,57 +35,57 @@ func (f FrequencyPlanEndDevice) Parse(file string) (Definition, error) { func (f FrequencyPlanEndDevice) Validate() error { for i, subBand := range f.SubBands { if err := subBand.Validate(); err != nil { - return fmt.Errorf("SubBand %d: %s", i, err) + return fmt.Errorf("SubBand %d: %w", i, err) } } for i, channel := range f.Channels { if err := channel.Validate(); err != nil { - return fmt.Errorf("Channel %d: %s", i, err) + return fmt.Errorf("Channel %d: %w", i, err) } } if f.LoRaStandardChannel != nil { if err := f.LoRaStandardChannel.Validate(); err != nil { - return fmt.Errorf("LoRaStandardChannel: %s", err) + return fmt.Errorf("LoRaStandardChannel: %w", err) } } if f.FSKChannel != nil { if err := f.FSKChannel.Validate(); err != nil { - return fmt.Errorf("FSKChannel: %s", err) + return fmt.Errorf("FSKChannel: %w", err) } } if f.TimeOffAir != nil { if err := f.TimeOffAir.Validate(); err != nil { - return fmt.Errorf("TimeOffAir: %s", err) + return fmt.Errorf("TimeOffAir: %w", err) } } if f.DwellTime != nil { if err := f.DwellTime.Validate(); err != nil { - return fmt.Errorf("DwellTime: %s", err) + return fmt.Errorf("DwellTime: %w", err) } } if f.ListenBeforeTalk != nil { if err := f.ListenBeforeTalk.Validate(); err != nil { - return fmt.Errorf("ListenBeforeTalk: %s", err) + return fmt.Errorf("ListenBeforeTalk: %w", err) } } if f.PingSlot != nil { if err := f.PingSlot.Validate(); err != nil { - return fmt.Errorf("PingSlot: %s", err) + return fmt.Errorf("PingSlot: %w", err) } } if f.PingSlotDefaultDataRate != nil { if err := validateDataRate(*f.PingSlotDefaultDataRate); err != nil { - return fmt.Errorf("PingSlotDefaultDataRate: %s", err) + return fmt.Errorf("PingSlotDefaultDataRate: %w", err) } } if f.RX2Channel != nil { if err := f.RX2Channel.Validate(); err != nil { - return fmt.Errorf("RX2Channel: %s", err) + return fmt.Errorf("RX2Channel: %w", err) } } if f.RX2DefaultDataRate != nil { if err := validateDataRate(*f.RX2DefaultDataRate); err != nil { - return fmt.Errorf("RX2DefaultDataRate: %s", err) + return fmt.Errorf("RX2DefaultDataRate: %w", err) } } return nil diff --git a/internal/model/gateway-frequency-plan.go b/internal/model/gateway-frequency-plan.go index a5ff6cf..4e27aa1 100644 --- a/internal/model/gateway-frequency-plan.go +++ b/internal/model/gateway-frequency-plan.go @@ -32,37 +32,37 @@ func (f FrequencyPlanGateway) Parse(file string) (Definition, error) { func (f FrequencyPlanGateway) Validate() error { for i, subBand := range f.SubBands { if err := subBand.Validate(); err != nil { - return fmt.Errorf("SubBand %d: %s", i, err) + return fmt.Errorf("SubBand %d: %w", i, err) } } for i, channel := range f.Channels { if err := channel.Validate(); err != nil { - return fmt.Errorf("Channel %d: %s", i, err) + return fmt.Errorf("Channel %d: %w", i, err) } } if f.LoRaStandardChannel != nil { if err := f.LoRaStandardChannel.Validate(); err != nil { - return fmt.Errorf("LoRaStandardChannel: %s", err) + return fmt.Errorf("LoRaStandardChannel: %w", err) } } if f.FSKChannel != nil { if err := f.FSKChannel.Validate(); err != nil { - return fmt.Errorf("FSKChannel: %s", err) + return fmt.Errorf("FSKChannel: %w", err) } } if f.TimeOffAir != nil { if err := f.TimeOffAir.Validate(); err != nil { - return fmt.Errorf("TimeOffAir: %s", err) + return fmt.Errorf("TimeOffAir: %w", err) } } if f.DwellTime != nil { if err := f.DwellTime.Validate(); err != nil { - return fmt.Errorf("DwellTime: %s", err) + return fmt.Errorf("DwellTime: %w", err) } } for i, radio := range f.Radios { if err := radio.Validate(); err != nil { - return fmt.Errorf("Radio %d: %s", i, err) + return fmt.Errorf("Radio %d: %w", i, err) } } return nil