UnwrapTypedError walks the wrap chain and returns the first error that embeds Problem (i.e. any typed error in this package). Returns the typed error itself (as error) so callers — notably JSON marshaling — see the concrete value's own struct tags rather than an opaque wrapper.
(err error)
| 28 | // error itself (as error) so callers — notably JSON marshaling — see the |
| 29 | // concrete value's own struct tags rather than an opaque wrapper. |
| 30 | func UnwrapTypedError(err error) (error, bool) { |
| 31 | var c problemCarrier |
| 32 | if errors.As(err, &c) { |
| 33 | if e, ok := c.(error); ok { |
| 34 | return e, true |
| 35 | } |
| 36 | } |
| 37 | return nil, false |
| 38 | } |
| 39 | |
| 40 | // CategoryOf returns the error's Category for metrics/logging/dispatch routing. |
| 41 | // Falls back to CategoryInternal for non-typed errors. |