Main-locked threads are panic wrapped

This commit is contained in:
2025-11-24 19:43:25 -05:00
parent f97f5010e2
commit 5d25b3fb9a
2 changed files with 45 additions and 19 deletions

32
util.go
View File

@@ -14,16 +14,34 @@ import "sync/atomic"
import "unicode/utf8"
import "runtime/debug"
func panicErr(message any, stack []byte) (err error) {
if panErr, ok := message.(error); ok {
err = panErr
type panicError struct {
wrapped error
stack []byte
}
func (this panicError) Error() string {
if this.stack == nil {
return this.wrapped.Error()
} else {
err = errors.New(fmt.Sprint(message))
return fmt.Sprintf("%v: %s", this.wrapped, this.stack)
}
if stack != nil {
err = fmt.Errorf("%w: %s", err, stack)
}
func (this panicError) Unwrap() error {
return this.wrapped
}
func panicErr(message any, stack []byte) (err error) {
var wrapped error
if panErr, ok := message.(error); ok {
wrapped = panErr
} else {
wrapped = errors.New(fmt.Sprint(message))
}
return panicError {
wrapped: wrapped,
stack: stack,
}
return err
}
func defaul[T comparable](value, def T) T {