chore(all): review error wrappings
- remove repetitive `cannot` and `failed` prefixes - rename `unmarshaling` to `decoding`
This commit is contained in:
@@ -11,12 +11,12 @@ import (
|
||||
func configureDevice(client *wgctrl.Client, settings Settings) (err error) {
|
||||
deviceConfig, err := makeDeviceConfig(settings)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot make device configuration: %w", err)
|
||||
return fmt.Errorf("making device configuration: %w", err)
|
||||
}
|
||||
|
||||
err = client.ConfigureDevice(settings.InterfaceName, deviceConfig)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot configure device: %w", err)
|
||||
return fmt.Errorf("configuring device: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -117,5 +117,5 @@ func Test_netlink_Wireguard_addRule(t *testing.T) {
|
||||
_ = nilCleanup() // in case it succeeds
|
||||
}
|
||||
require.Error(t, err)
|
||||
assert.Equal(t, "cannot add rule ip rule 10000: from all to all table 999: file exists", err.Error())
|
||||
assert.EqualError(t, err, "adding rule ip rule 10000: from all to all table 999: file exists")
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ func (w *Wireguard) addRoute(link netlink.Link, dst *net.IPNet,
|
||||
err = w.netlink.RouteAdd(route)
|
||||
if err != nil {
|
||||
return fmt.Errorf(
|
||||
"cannot add route for link %s, destination %s and table %d: %w",
|
||||
"adding route for link %s, destination %s and table %d: %w",
|
||||
link.Attrs().Name, dst, firewallMark, err)
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ func Test_Wireguard_addRoute(t *testing.T) {
|
||||
Table: firewallMark,
|
||||
},
|
||||
routeAddErr: errDummy,
|
||||
err: errors.New("cannot add route for link a_bridge, destination 1.2.3.4/32 and table 51820: dummy"), //nolint:lll
|
||||
err: errors.New("adding route for link a_bridge, destination 1.2.3.4/32 and table 51820: dummy"), //nolint:lll
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -15,13 +15,13 @@ func (w *Wireguard) addRule(rulePriority, firewallMark, family int) (
|
||||
rule.Table = firewallMark
|
||||
rule.Family = family
|
||||
if err := w.netlink.RuleAdd(rule); err != nil {
|
||||
return nil, fmt.Errorf("cannot add rule %s: %w", rule, err)
|
||||
return nil, fmt.Errorf("adding rule %s: %w", rule, err)
|
||||
}
|
||||
|
||||
cleanup = func() error {
|
||||
err := w.netlink.RuleDel(rule)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot delete rule %s: %w", rule, err)
|
||||
return fmt.Errorf("deleting rule %s: %w", rule, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ func Test_Wireguard_addRule(t *testing.T) {
|
||||
Family: family,
|
||||
},
|
||||
ruleAddErr: errDummy,
|
||||
err: errors.New("cannot add rule ip rule 987: from all to all table 456: dummy"),
|
||||
err: errors.New("adding rule ip rule 987: from all to all table 456: dummy"),
|
||||
},
|
||||
"rule delete error": {
|
||||
expectedRule: &netlink.Rule{
|
||||
@@ -71,7 +71,7 @@ func Test_Wireguard_addRule(t *testing.T) {
|
||||
Family: family,
|
||||
},
|
||||
ruleDelErr: errDummy,
|
||||
cleanupErr: errors.New("cannot delete rule ip rule 987: from all to all table 456: dummy"),
|
||||
cleanupErr: errors.New("deleting rule ip rule 987: from all to all table 456: dummy"),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user