Cause returns the underlying cause of the error, if possible. An error value has a cause if it implements the following interface: type causer interface { Cause() error } If the error does not implement Cause, the original error will be returned. If the error is nil, nil will be returned without f
(err error)
| 273 | // be returned. If the error is nil, nil will be returned without further |
| 274 | // investigation. |
| 275 | func Cause(err error) error { |
| 276 | type causer interface { |
| 277 | Cause() error |
| 278 | } |
| 279 | |
| 280 | for err != nil { |
| 281 | cause, ok := err.(causer) |
| 282 | if !ok { |
| 283 | break |
| 284 | } |
| 285 | err = cause.Cause() |
| 286 | } |
| 287 | return err |
| 288 | } |
searching dependent graphs…