|
4 | 4 | // user defined error parameters. |
5 | 5 | // |
6 | 6 | // Terrors can be used to wrap any object that satisfies the error interface: |
| 7 | +// |
7 | 8 | // terr := terrors.Wrap(err, map[string]string{"context": "my_context"}) |
8 | 9 | // |
9 | 10 | // Terrors can be instantiated directly: |
10 | | -// err := terrors.New("not_found", "object not found", map[string]string{ |
| 11 | +// |
| 12 | +// err := terrors.New("not_found", "object not found", map[string]string{ |
11 | 13 | // "context": "my_context" |
12 | 14 | // }) |
13 | 15 | // |
14 | 16 | // Terrors offers built-in functions for instantiating Errors with common codes: |
| 17 | +// |
15 | 18 | // err := terrors.NotFound("config_file", "config file not found", map[string]string{ |
16 | 19 | // "context": my_context |
17 | 20 | // }) |
@@ -208,6 +211,7 @@ func addParams(err *Error, params map[string]string) *Error { |
208 | 211 | Params: copiedParams, |
209 | 212 | StackFrames: err.StackFrames, |
210 | 213 | IsRetryable: err.IsRetryable, |
| 214 | + cause: err.cause, |
211 | 215 | } |
212 | 216 | } |
213 | 217 |
|
@@ -237,7 +241,9 @@ func (p *Error) PrefixMatches(prefixParts ...string) bool { |
237 | 241 | // `PrefixMatches`, so if you were previously matching against a part of the string returned from error.Error() that |
238 | 242 | // is _not_ the prefix, then this will be a breaking change. In this case you should update the string to match the |
239 | 243 | // prefix. If this is not possible, you can match against the entire error string explicitly, for example: |
240 | | -// strings.Contains(err.Error(), "context deadline exceeded") |
| 244 | +// |
| 245 | +// strings.Contains(err.Error(), "context deadline exceeded") |
| 246 | +// |
241 | 247 | // But we consider this bad practice and is part of the motivation for deprecating Matches in the first place. |
242 | 248 | func Matches(err error, match string) bool { |
243 | 249 | if terr, ok := Wrap(err, nil).(*Error); ok { |
|
0 commit comments