ErrorGetContext gets a value from the error's context. If the error has not been wrapped, it returns an empty string.
(err error, key string)
| 18 | // ErrorGetContext gets a value from the error's context. If the error has not |
| 19 | // been wrapped, it returns an empty string. |
| 20 | func GetContext(err error, key string) interface{} { |
| 21 | if e, ok := err.(withContext); ok { |
| 22 | return e.Get(key) |
| 23 | } |
| 24 | return "" |
| 25 | } |
| 26 | |
| 27 | // ErrorDelContext removes a value from the error's context. If the error has |
| 28 | // not been wrapped, it does nothing. |