MCPcopy Index your code
hub / github.com/jetify-com/devbox / ExampleErrorf

Function ExampleErrorf

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

Source from the content-addressed store, hash-verified

28}
29
30func ExampleErrorf() {
31 // Errors created with Errorf are redacted by omitting any arguments not
32 // marked as safe. The literal portion of the format string is kept.
33 wrapped := errors.New("not found")
34 name := "Alex"
35 id := 5
36 err := Errorf("error getting user %s with ID %d: %w", name, Safe(id), wrapped)
37
38 fmt.Println("Normal:", err)
39 fmt.Println("Redacted:", Error(err))
40 // Output:
41 // Normal: error getting user Alex with ID 5: not found
42 // Redacted: error getting user <redacted string> with ID 5: <redacted *errors.errorString>
43}
44
45func ExampleError_wrapped() {
46 // If an error wraps another, then redacting it results in a message with the

Callers

nothing calls this directly

Calls 3

ErrorfFunction · 0.85
SafeFunction · 0.85
ErrorFunction · 0.70

Tested by

no test coverage detected