MCPcopy Create free account
hub / github.com/chain/txvm / Error

Function Error

log/log.go:197–205  ·  view source on GitHub ↗

Error prints a log entry containing an error message assigned to the "error" key. Optionally, an error message prefix can be included. Prefix arguments are handled as in fmt.Print.

(ctx context.Context, err error, a ...interface{})

Source from the content-addressed store, hash-verified

195// Optionally, an error message prefix can be included. Prefix arguments are
196// handled as in fmt.Print.
197func Error(ctx context.Context, err error, a ...interface{}) {
198 Helper()
199 if _, hasStack := errors.Stack(err).Next(); len(a) > 0 && hasStack {
200 err = errors.Wrap(err, a...) // keep err's stack
201 } else if len(a) > 0 {
202 err = fmt.Errorf("%s: %s", fmt.Sprint(a...), err) // don't add a stack here
203 }
204 Printkv(ctx, KeyError, err)
205}
206
207// formatKey ensures that the stringified key is valid for use in a
208// Splunk-style K=V format. It stubs out delimeter and quoter characters in

Callers 3

NewChainFunction · 0.92
TestErrorFunction · 0.85
TestHelperStackFunction · 0.85

Calls 4

StackFunction · 0.92
WrapFunction · 0.92
HelperFunction · 0.85
PrintkvFunction · 0.85

Tested by 2

TestErrorFunction · 0.68
TestHelperStackFunction · 0.68