WithDetail returns a new error that wraps err as a chain error messsage containing text as its additional context. Function Detail will return the given text when called on the new error value.
(err error, text string)
| 84 | // Function Detail will return the given text |
| 85 | // when called on the new error value. |
| 86 | func WithDetail(err error, text string) error { |
| 87 | if err == nil { |
| 88 | return nil |
| 89 | } |
| 90 | if text == "" { |
| 91 | return err |
| 92 | } |
| 93 | e1 := wrap(err, text, 1).(wrapperError) |
| 94 | e1.detail = append(e1.detail, text) |
| 95 | return e1 |
| 96 | } |
| 97 | |
| 98 | // WithDetailf is like WithDetail, except it formats |
| 99 | // the detail message as in fmt.Printf. |