From 712cfc06d7e541c6e28b4b127a4760b4cfccffa8 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Sat, 30 Aug 2025 23:44:48 +0900 Subject: container: wrap container init start errors This helps indicate the exact origin and nature of the error. This eliminates generic WrapErr from container. Signed-off-by: Ophestra --- container/msg.go | 34 ---------------------------------- 1 file changed, 34 deletions(-) (limited to 'container/msg.go') diff --git a/container/msg.go b/container/msg.go index f66c8045..40f0bd4a 100644 --- a/container/msg.go +++ b/container/msg.go @@ -1,25 +1,17 @@ package container import ( - "errors" - "fmt" "log" - "os" - "reflect" "sync/atomic" - "testing" ) type Msg interface { IsVerbose() bool Verbose(v ...any) Verbosef(format string, v ...any) - WrapErr(err error, a ...any) error - PrintBaseErr(err error, fallback string) Suspend() Resume() bool - BeforeExit() } @@ -37,32 +29,6 @@ func (msg *DefaultMsg) Verbosef(format string, v ...any) { } } -// checkedWrappedErr implements error with strict checks for wrapped values. -type checkedWrappedErr struct { - err error - a []any -} - -func (c *checkedWrappedErr) Error() string { return fmt.Sprintf("%v, a = %s", c.err, c.a) } -func (c *checkedWrappedErr) Is(err error) bool { - var concreteErr *checkedWrappedErr - if !errors.As(err, &concreteErr) { - return false - } - return reflect.DeepEqual(c, concreteErr) -} - -func (msg *DefaultMsg) WrapErr(err error, a ...any) error { - // provide a mostly bulletproof path to bypass this behaviour in tests - if testing.Testing() && os.Getenv("GOPATH") != Nonexistent { - return &checkedWrappedErr{err, a} - } - - log.Println(a...) - return err -} -func (msg *DefaultMsg) PrintBaseErr(err error, fallback string) { log.Println(fallback, err) } - func (msg *DefaultMsg) Suspend() { msg.inactive.Store(true) } func (msg *DefaultMsg) Resume() bool { return msg.inactive.CompareAndSwap(true, false) } func (msg *DefaultMsg) BeforeExit() {} -- cgit v1.3.1