ProblemOf extracts the embedded Problem via the non-exported problemCarrier interface. This is the supported way to read shared fields without depending on a specific typed error. A typed error whose embedded *Problem is nil is treated as "not a problem carrier" — returning (nil, true) here would c
(err error)
| 14 | // carrier" — returning (nil, true) here would cause CategoryOf / IsRetryable |
| 15 | // and other downstream readers to dereference nil. |
| 16 | func ProblemOf(err error) (*Problem, bool) { |
| 17 | var c problemCarrier |
| 18 | if errors.As(err, &c) { |
| 19 | if p := c.ProblemDetail(); p != nil { |
| 20 | return p, true |
| 21 | } |
| 22 | } |
| 23 | return nil, false |
| 24 | } |
| 25 | |
| 26 | // UnwrapTypedError walks the wrap chain and returns the first error that |
| 27 | // embeds Problem (i.e. any typed error in this package). Returns the typed |