RootCause walks up the "error chain" until it finds the root cause of an error.
(err error)
| 78 | |
| 79 | // RootCause walks up the "error chain" until it finds the root cause of an error. |
| 80 | func RootCause(err error) error { |
| 81 | for err != nil { |
| 82 | cause := Cause(err) |
| 83 | if cause == nil { |
| 84 | return err |
| 85 | } |
| 86 | err = cause |
| 87 | } |
| 88 | return err |
| 89 | } |
| 90 | |
| 91 | // Stack returns the entire error stack, including the given error. |
| 92 | func Stack(err error) (stack []error) { |