engine, pgp: Fixup incorrect error usage

Small fixups found by the next commit.
This commit is contained in:
James Shubin
2019-03-12 16:12:17 -04:00
parent 2bf43eae24
commit 54c81d6bb2
3 changed files with 8 additions and 8 deletions

View File

@@ -136,7 +136,7 @@ func (obj *ExecRes) Validate() error {
return errwrap.Wrapf(err, "error looking up current user") return errwrap.Wrapf(err, "error looking up current user")
} }
if currentUser.Uid != "0" { if currentUser.Uid != "0" {
return errwrap.Errorf("running as root is required if you want to use exec with a different user/group") return fmt.Errorf("running as root is required if you want to use exec with a different user/group")
} }
} }

View File

@@ -110,7 +110,7 @@ func (obj *HostnameRes) Watch() error {
// if we share the bus with others, we will get each others messages!! // if we share the bus with others, we will get each others messages!!
bus, err := util.SystemBusPrivateUsable() // don't share the bus connection! bus, err := util.SystemBusPrivateUsable() // don't share the bus connection!
if err != nil { if err != nil {
return errwrap.Wrap(err, "Failed to connect to bus") return errwrap.Wrapf(err, "failed to connect to bus")
} }
defer bus.Close() defer bus.Close()
// watch the PropertiesChanged signal on the hostname1 dbus path // watch the PropertiesChanged signal on the hostname1 dbus path
@@ -120,7 +120,7 @@ func (obj *HostnameRes) Watch() error {
dbusPropertiesIface, dbusPropertiesIface,
) )
if call := bus.BusObject().Call(engineUtil.DBusAddMatch, 0, args); call.Err != nil { if call := bus.BusObject().Call(engineUtil.DBusAddMatch, 0, args); call.Err != nil {
return errwrap.Wrap(call.Err, "Failed to subscribe to DBus events for hostname1") return errwrap.Wrapf(call.Err, "failed to subscribe to DBus events for hostname1")
} }
defer bus.BusObject().Call(engineUtil.DBusRemoveMatch, 0, args) // ignore the error defer bus.BusObject().Call(engineUtil.DBusRemoveMatch, 0, args) // ignore the error
@@ -153,12 +153,12 @@ func (obj *HostnameRes) updateHostnameProperty(object dbus.BusObject, expectedVa
return false, errwrap.Wrapf(err, "failed to get org.freedesktop.hostname1.%s", property) return false, errwrap.Wrapf(err, "failed to get org.freedesktop.hostname1.%s", property)
} }
if propertyObject.Value() == nil { if propertyObject.Value() == nil {
return false, errwrap.Errorf("Unexpected nil value received when reading property %s", property) return false, fmt.Errorf("unexpected nil value received when reading property %s", property)
} }
propertyValue, ok := propertyObject.Value().(string) propertyValue, ok := propertyObject.Value().(string)
if !ok { if !ok {
return false, fmt.Errorf("Received unexpected type as %s value, expected string got '%T'", property, propertyValue) return false, fmt.Errorf("received unexpected type as %s value, expected string got '%T'", property, propertyValue)
} }
// expected value and actual value match => checkOk // expected value and actual value match => checkOk
@@ -185,7 +185,7 @@ func (obj *HostnameRes) updateHostnameProperty(object dbus.BusObject, expectedVa
func (obj *HostnameRes) CheckApply(apply bool) (checkOK bool, err error) { func (obj *HostnameRes) CheckApply(apply bool) (checkOK bool, err error) {
conn, err := util.SystemBusPrivateUsable() conn, err := util.SystemBusPrivateUsable()
if err != nil { if err != nil {
return false, errwrap.Wrap(err, "Failed to connect to the private system bus") return false, errwrap.Wrapf(err, "failed to connect to the private system bus")
} }
defer conn.Close() defer conn.Close()

View File

@@ -217,13 +217,13 @@ func ParseIdentity(identity string) (name, comment, email string, err error) {
// get name // get name
n := strings.Split(identity, " <") n := strings.Split(identity, " <")
if len(n) != 2 { if len(n) != 2 {
return "", "", "", errwrap.Wrap(err, "user string mal formated") return "", "", "", errwrap.Wrapf(err, "user string mal formated")
} }
// get email and comment // get email and comment
ec := strings.Split(n[1], "> ") ec := strings.Split(n[1], "> ")
if len(ec) != 2 { if len(ec) != 2 {
return "", "", "", errwrap.Wrap(err, "user string mal formated") return "", "", "", errwrap.Wrapf(err, "user string mal formated")
} }
return n[0], ec[1], ec[0], nil return n[0], ec[1], ec[0], nil