aboutsummaryrefslogtreecommitdiffhomepage
path: root/container/container.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-08-31 11:57:59 +0900
committerOphestra <cat@gensokyo.uk>2025-08-31 11:57:59 +0900
commit780e3e546581dd4a46b887310a665eea06f3279a (patch)
treef7186c712fb4e0f62052e147968196bc45a17996 /container/container.go
parent712cfc06d7e541c6e28b4b127a4760b4cfccffa8 (diff)
container/msg: optionally provide error messages
This makes handling of fatal errors a lot less squirmy. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/container.go')
-rw-r--r--container/container.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/container/container.go b/container/container.go
index 2301ce75..dee4a44d 100644
--- a/container/container.go
+++ b/container/container.go
@@ -132,6 +132,24 @@ func (e *StartError) Error() string {
return e.Step + ": " + e.Err.Error()
}
+// Message returns a user-facing error message.
+func (e *StartError) Message() string {
+ if e.Passthrough {
+ switch {
+ case errors.As(e.Err, new(*os.PathError)),
+ errors.As(e.Err, new(*os.SyscallError)):
+ return "cannot " + e.Err.Error()
+
+ default:
+ return e.Err.Error()
+ }
+ }
+ if e.Origin {
+ return e.Step
+ }
+ return "cannot " + e.Error()
+}
+
// Start starts the container init. The init process blocks until Serve is called.
func (p *Container) Start() error {
if p.cmd != nil {