GetDomain extracts the domain of the given error, or NoDomain if the error's cause does not have a domain annotation.
(err error)
| 34 | // GetDomain extracts the domain of the given error, or NoDomain if |
| 35 | // the error's cause does not have a domain annotation. |
| 36 | func GetDomain(err error) Domain { |
| 37 | for { |
| 38 | if b, ok := err.(*withDomain); ok { |
| 39 | return b.domain |
| 40 | } |
| 41 | // Recurse to the cause. |
| 42 | if c := errbase.UnwrapOnce(err); c != nil { |
| 43 | err = c |
| 44 | continue |
| 45 | } |
| 46 | break |
| 47 | } |
| 48 | return NoDomain |
| 49 | } |
| 50 | |
| 51 | // WithDomain wraps an error so that it appears to come from the given domain. |
| 52 | // |
searching dependent graphs…