From b12c290f12ab65754d6ce8a461fe641e245cb09c Mon Sep 17 00:00:00 2001 From: Ophestra Date: Sat, 30 Aug 2025 16:51:40 +0900 Subject: [PATCH] system/wayland: improve error descriptions A lot of these errors have very short and nondescript descriptions. These are only returned on incorrect API usage, but it makes sense to make them more descriptive anyway. Signed-off-by: Ophestra --- system/wayland/conn.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/system/wayland/conn.go b/system/wayland/conn.go index a930fc0..86e0a28 100644 --- a/system/wayland/conn.go +++ b/system/wayland/conn.go @@ -10,6 +10,7 @@ import ( "syscall" ) +// Conn represents a connection to the wayland display server. type Conn struct { conn *net.UnixConn @@ -25,7 +26,7 @@ func (c *Conn) Attach(p string) (err error) { defer c.mu.Unlock() if c.conn != nil { - return errors.New("attached") + return errors.New("socket already attached") } c.conn, err = net.DialUnix("unix", nil, &net.UnixAddr{Name: p, Net: "unix"}) @@ -51,15 +52,16 @@ func (c *Conn) Close() error { return nil } -func (c *Conn) Bind(p, appID, instanceID string) (*os.File, error) { +// Bind binds the new socket to pathname. +func (c *Conn) Bind(pathname, appID, instanceID string) (*os.File, error) { c.mu.Lock() defer c.mu.Unlock() if c.conn == nil { - return nil, errors.New("not attached") + return nil, errors.New("socket not attached") } if c.done != nil { - return nil, errors.New("bound") + return nil, errors.New("socket already bound") } if rc, err := c.conn.SyscallConn(); err != nil { @@ -67,7 +69,7 @@ func (c *Conn) Bind(p, appID, instanceID string) (*os.File, error) { return nil, err } else { c.done = make(chan struct{}) - return bindRawConn(c.done, rc, p, appID, instanceID) + return bindRawConn(c.done, rc, pathname, appID, instanceID) } }