M2: improve error messages with actionable suggestions

udisks2 connection and device listing errors now suggest checking the
service. Device-not-found errors suggest 'arca status' or 'arca init'.
Failed cryptsetup token unlock hints at missing FIDO2/TPM2 key.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-24 07:59:26 -07:00
parent ea7e09bdfb
commit 26aa202b05
2 changed files with 6 additions and 6 deletions

View File

@@ -16,7 +16,7 @@ type Client struct {
func NewClient() (*Client, error) {
conn, err := dbus.SystemBus()
if err != nil {
return nil, fmt.Errorf("connecting to system bus: %w", err)
return nil, fmt.Errorf("cannot connect to udisks2 — is the udisks2 service running? (%w)", err)
}
return &Client{conn: conn}, nil
}
@@ -39,7 +39,7 @@ func (c *Client) FindDevice(uuid, pathOrName string) (*BlockDevice, error) {
return &devices[i], nil
}
}
return nil, fmt.Errorf("no device with UUID %s", uuid)
return nil, fmt.Errorf("no device with UUID %s — run 'arca status' to list devices", uuid)
}
for i := range devices {
@@ -47,7 +47,7 @@ func (c *Client) FindDevice(uuid, pathOrName string) (*BlockDevice, error) {
return &devices[i], nil
}
}
return nil, fmt.Errorf("device %s not found", pathOrName)
return nil, fmt.Errorf("device %s not found — run 'arca status' to list devices or 'arca init' to generate config", pathOrName)
}
// ListEncryptedDevices returns all block devices with the Encrypted interface.
@@ -152,7 +152,7 @@ func (c *Client) listBlockDevices() ([]BlockDevice, error) {
var managed map[dbus.ObjectPath]map[string]map[string]dbus.Variant
err := obj.Call(ifaceObjectManager+".GetManagedObjects", 0).Store(&managed)
if err != nil {
return nil, fmt.Errorf("listing devices: %w", err)
return nil, fmt.Errorf("listing devices — is the udisks2 service running? (%w)", err)
}
var devices []BlockDevice