WithType is responsible for annotating an already existing error so that it also satisfies that of a ConstError. The resultant error returned should satisfy Is(err, errType). If err is nil then a nil error will also be returned. Now with Go's Is, As and Unwrap support it no longer makes sense to Wr
(err error, errType ConstError)
| 103 | // WithType aims to solve some of the usefulness of Wrap with the ability to |
| 104 | // make a pre-existing error also satisfy a ConstError type. |
| 105 | func WithType(err error, errType ConstError) error { |
| 106 | if err == nil { |
| 107 | return nil |
| 108 | } |
| 109 | return &errWithType{ |
| 110 | error: err, |
| 111 | errType: errType, |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | // Timeoutf returns an error which satisfies Is(err, Timeout) and the Locationer |
| 116 | // interface. |
no outgoing calls
searching dependent graphs…