|
|
|
@ -13,22 +13,10 @@ import ( |
|
|
|
|
"context" |
|
|
|
|
"errors" |
|
|
|
|
"strings" |
|
|
|
|
"sync" |
|
|
|
|
|
|
|
|
|
"github.com/mediocregopher/mediocre-go-lib/v2/mctx" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
var strBuilderPool = sync.Pool{ |
|
|
|
|
New: func() interface{} { return new(strings.Builder) }, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func putStrBuilder(sb *strings.Builder) { |
|
|
|
|
sb.Reset() |
|
|
|
|
strBuilderPool.Put(sb) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
type annotateKey string |
|
|
|
|
|
|
|
|
|
// Error wraps an error such that contextual and stacktrace information is
|
|
|
|
@ -62,7 +50,7 @@ func (e Error) FullError() string { |
|
|
|
|
sb.WriteString(": ") |
|
|
|
|
|
|
|
|
|
// if there's no newlines then print v inline with k
|
|
|
|
|
if strings.Index(v, "\n") < 0 { |
|
|
|
|
if strings.Contains(v, "\n") { |
|
|
|
|
sb.WriteString(v) |
|
|
|
|
continue |
|
|
|
|
} |
|
|
|
@ -111,6 +99,7 @@ func Wrap(ctx context.Context, err error) error { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// New is a shortcut for:
|
|
|
|
|
//
|
|
|
|
|
// merr.WrapSkip(ctx, errors.New(str), 1)
|
|
|
|
|
func New(ctx context.Context, str string) error { |
|
|
|
|
return WrapSkip(ctx, errors.New(str), 1) |
|
|
|
|