WithClassification wraps err so future calls to Classify return classified instead of re-deriving it from err.Error().
(err error, classified ClassifiedError)
| 100 | // WithClassification wraps err so future calls to Classify return |
| 101 | // classified instead of re-deriving it from err.Error(). |
| 102 | func WithClassification(err error, classified ClassifiedError) error { |
| 103 | if err == nil { |
| 104 | return nil |
| 105 | } |
| 106 | return &classifiedError{ |
| 107 | cause: err, |
| 108 | classified: normalizeClassification(classified), |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | type classifiedError struct { |
| 113 | cause error |