diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-08-30 22:49:12 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-08-30 22:49:12 +0900 |
| commit | f5abce9df5727904a1daa246025a87c4bfe62553 (patch) | |
| tree | 7e8c29b83e97532954dee8adb5f86962eaebca34 /system/xhost.go | |
| parent | ddb003e39b64c2417cabc291383d99b4ad64ac8f (diff) | |
system: wrap op errors
This passes more information allowing for better error handling. This eliminates generic WrapErr from system.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'system/xhost.go')
| -rw-r--r-- | system/xhost.go | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/system/xhost.go b/system/xhost.go index 7bbc3725..27b2fc64 100644 --- a/system/xhost.go +++ b/system/xhost.go @@ -1,8 +1,6 @@ package system import ( - "fmt" - "hakurei.app/system/internal/xcb" ) @@ -18,36 +16,25 @@ func (sys *I) ChangeHosts(username string) *I { type XHost string -func (x XHost) Type() Enablement { - return EX11 -} +func (x XHost) Type() Enablement { return EX11 } func (x XHost) apply(*I) error { msg.Verbosef("inserting entry %s to X11", x) - return wrapErrSuffix(xcb.ChangeHosts(xcb.HostModeInsert, xcb.FamilyServerInterpreted, "localuser\x00"+string(x)), - fmt.Sprintf("cannot insert entry %s to X11:", x)) + return newOpError("xhost", + xcb.ChangeHosts(xcb.HostModeInsert, xcb.FamilyServerInterpreted, "localuser\x00"+string(x)), false) } func (x XHost) revert(_ *I, ec *Criteria) error { if ec.hasType(x) { msg.Verbosef("deleting entry %s from X11", x) - return wrapErrSuffix(xcb.ChangeHosts(xcb.HostModeDelete, xcb.FamilyServerInterpreted, "localuser\x00"+string(x)), - fmt.Sprintf("cannot delete entry %s from X11:", x)) + return newOpError("xhost", + xcb.ChangeHosts(xcb.HostModeDelete, xcb.FamilyServerInterpreted, "localuser\x00"+string(x)), false) } else { msg.Verbosef("skipping entry %s in X11", x) return nil } } -func (x XHost) Is(o Op) bool { - x0, ok := o.(XHost) - return ok && x == x0 -} - -func (x XHost) Path() string { - return string(x) -} - -func (x XHost) String() string { - return string("SI:localuser:" + x) -} +func (x XHost) Is(o Op) bool { x0, ok := o.(XHost); return ok && x == x0 } +func (x XHost) Path() string { return string(x) } +func (x XHost) String() string { return string("SI:localuser:" + x) } |
