MCPcopy
hub / github.com/jetify-com/devbox / ExampleError_wrapped

Function ExampleError_wrapped

internal/redact/redact_test.go:45–59  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

43}
44
45func ExampleError_wrapped() {
46 // If an error wraps another, then redacting it results in a message with the
47 // redacted version of each error in the chain up until the first redactable
48 // error.
49 name := "Alex"
50 err := fmt.Errorf("fatal error: %w",
51 Errorf("error getting user %s: %w", name,
52 errors.New("not found")))
53
54 fmt.Println("Normal:", err)
55 fmt.Println("Redacted:", Error(err))
56 // Output:
57 // Normal: fatal error: error getting user Alex: not found
58 // Redacted: <redacted *fmt.wrapError>: error getting user <redacted string>: <redacted *errors.errorString>
59}
60
61func TestNil(t *testing.T) {
62 checkUnredactedError(t, nil, "<nil>")

Callers

nothing calls this directly

Calls 2

ErrorfFunction · 0.85
ErrorFunction · 0.70

Tested by

no test coverage detected