system: wrap op errors
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 1m51s
Test / Hakurei (push) Successful in 3m18s
Test / Hpkg (push) Successful in 3m41s
Test / Sandbox (race detector) (push) Successful in 4m7s
Test / Hakurei (race detector) (push) Successful in 5m18s
Test / Flake checks (push) Successful in 1m35s
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 1m51s
Test / Hakurei (push) Successful in 3m18s
Test / Hpkg (push) Successful in 3m41s
Test / Sandbox (race detector) (push) Successful in 4m7s
Test / Hakurei (race detector) (push) Successful in 5m18s
Test / Flake checks (push) Successful in 1m35s
This passes more information allowing for better error handling. This eliminates generic WrapErr from system. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -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) }
|
||||
|
||||
Reference in New Issue
Block a user