| 14 | ) |
| 15 | |
| 16 | func ExampleError() { |
| 17 | // Each error string in a chain of wrapped errors is redacted with a |
| 18 | // placeholder describing the error's type. |
| 19 | wrapped := errors.New("not found") |
| 20 | name := "Alex" |
| 21 | err := fmt.Errorf("error getting user %s: %w", name, wrapped) |
| 22 | |
| 23 | fmt.Println("Normal:", err) |
| 24 | fmt.Println("Redacted:", Error(err)) |
| 25 | // Output: |
| 26 | // Normal: error getting user Alex: not found |
| 27 | // Redacted: <redacted *fmt.wrapError>: <redacted *errors.errorString> |
| 28 | } |
| 29 | |
| 30 | func ExampleErrorf() { |
| 31 | // Errors created with Errorf are redacted by omitting any arguments not |