internal/wayland: increase error detail
All checks were successful
Test / Create distribution (push) Successful in 35s
Test / Sandbox (push) Successful in 2m14s
Test / Hakurei (push) Successful in 3m16s
Test / Hpkg (push) Successful in 4m5s
Test / Sandbox (race detector) (push) Successful in 4m18s
Test / Hakurei (race detector) (push) Successful in 5m8s
Test / Flake checks (push) Successful in 1m21s

This includes targeted paths in the returned errors.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-11-16 02:09:50 +09:00
parent 00771efeb4
commit 3c204b9b40
4 changed files with 46 additions and 24 deletions

View File

@@ -38,6 +38,10 @@ type (
Error struct {
// Where the failure occurred.
Cause Res
// Attempted pathname socket.
Path string
// Pathname socket to host server. Omitted for libwayland errors.
Host string
// Global errno value set during the fault.
Errno error
}
@@ -69,8 +73,8 @@ const (
// RListen is returned if listen failed. The global errno is set.
RListen Res = C.HAKUREI_WAYLAND_LISTEN
// RHostCreate is returned if ensuring pathname availability failed. Returned by [New].
RHostCreate Res = C.HAKUREI_WAYLAND_HOST_CREAT
// RCreate is returned if ensuring pathname availability failed. Returned by [New].
RCreate Res = C.HAKUREI_WAYLAND_CREAT
// RHostSocket is returned if socket failed for host server. Returned by [New].
RHostSocket Res = C.HAKUREI_WAYLAND_HOST_SOCKET
// RHostConnect is returned if connect failed for host server. Returned by [New].
@@ -96,21 +100,25 @@ func (e *Error) Error() string {
case RNotAvail:
return "compositor does not implement security_context_v1"
case RSocket, RBind, RListen:
case RSocket:
if e.Errno == nil {
return "socket operation failed"
}
return e.Errno.Error()
return "socket: " + e.Errno.Error()
case RBind:
return e.withPrefix("cannot bind " + e.Path)
case RListen:
return e.withPrefix("cannot listen on " + e.Path)
case RHostCreate:
case RCreate:
if e.Errno == nil {
return "cannot ensure wayland pathname socket"
}
return e.Errno.Error()
case RHostSocket:
return e.withPrefix("socket for host wayland server")
return e.withPrefix("socket")
case RHostConnect:
return e.withPrefix("connect to host wayland server")
return e.withPrefix("cannot connect to " + e.Host)
default:
return e.withPrefix("impossible outcome") /* not reached */
@@ -142,6 +150,7 @@ func securityContextBind(
if e.Cause == RSuccess {
return nil
}
e.Path = socketPath
return &e
}