container: improve error message fallback
All checks were successful
Test / Create distribution (push) Successful in 36s
Test / Sandbox (push) Successful in 2m38s
Test / Sandbox (race detector) (push) Successful in 4m42s
Test / Hpkg (push) Successful in 4m52s
Test / Hakurei (push) Successful in 5m0s
Test / Hakurei (race detector) (push) Successful in 6m27s
Test / Flake checks (push) Successful in 1m28s
All checks were successful
Test / Create distribution (push) Successful in 36s
Test / Sandbox (push) Successful in 2m38s
Test / Sandbox (race detector) (push) Successful in 4m42s
Test / Hpkg (push) Successful in 4m52s
Test / Hakurei (push) Successful in 5m0s
Test / Hakurei (race detector) (push) Successful in 6m27s
Test / Flake checks (push) Successful in 1m28s
This now falls back to message.Error if no other concrete type is matched. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
parent
d5fb179012
commit
96dd7abd80
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user