aboutsummaryrefslogtreecommitdiffhomepage
path: root/container
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-12-08 22:45:54 +0900
committerOphestra <cat@gensokyo.uk>2025-12-08 22:45:54 +0900
commit96dd7abd806f6639703968a7f8267901d5955dad (patch)
tree770c4dde71c1ae128b25a206308a2cbb6f713609 /container
parentd5fb179012e36436a81761502948c91d44d21cc3 (diff)
container: improve error message fallback
This now falls back to message.Error if no other concrete type is matched. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container')
-rw-r--r--container/errors.go35
1 files changed, 20 insertions, 15 deletions
diff --git a/container/errors.go b/container/errors.go
index 884c8a04..2bcb4974 100644
--- a/container/errors.go
+++ b/container/errors.go
@@ -7,31 +7,36 @@ import (
"hakurei.app/container/check"
"hakurei.app/container/vfs"
+ "hakurei.app/message"
)
// messageFromError returns a printable error message for a supported concrete type.
-func messageFromError(err error) (string, bool) {
- if m, ok := messagePrefixP[MountError]("cannot ", err); ok {
- return m, ok
+func messageFromError(err error) (m string, ok bool) {
+ if m, ok = messagePrefixP[MountError]("cannot ", err); ok {
+ return
}
- if m, ok := messagePrefixP[os.PathError]("cannot ", err); ok {
- return m, ok
+ if m, ok = messagePrefixP[os.PathError]("cannot ", err); ok {
+ return
}
- if m, ok := messagePrefixP[check.AbsoluteError]("", err); ok {
- return m, ok
+ if m, ok = messagePrefixP[check.AbsoluteError](zeroString, err); ok {
+ return
}
- if m, ok := messagePrefix[OpRepeatError]("", err); ok {
- return m, ok
+ if m, ok = messagePrefix[OpRepeatError](zeroString, err); ok {
+ return
}
- if m, ok := messagePrefix[OpStateError]("", err); ok {
- return m, ok
+ if m, ok = messagePrefix[OpStateError](zeroString, err); ok {
+ return
}
- if m, ok := messagePrefixP[vfs.DecoderError]("cannot ", err); ok {
- return m, ok
+ if m, ok = messagePrefixP[vfs.DecoderError]("cannot ", err); ok {
+ return
}
- if m, ok := messagePrefix[TmpfsSizeError]("", err); ok {
- return m, ok
+ if m, ok = messagePrefix[TmpfsSizeError](zeroString, err); ok {
+ return
+ }
+
+ if m, ok = message.GetMessage(err); ok {
+ return
}
return zeroString, false