mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-05-14 00:51:12 +03:00
26 lines
359 B
Go
26 lines
359 B
Go
package errors
|
|
|
|
type hasInnerError interface {
|
|
// Unwrap returns the underlying error of this one.
|
|
Unwrap() error
|
|
}
|
|
|
|
func Cause(err error) error {
|
|
if err == nil {
|
|
return nil
|
|
}
|
|
L:
|
|
for {
|
|
switch inner := err.(type) {
|
|
case hasInnerError:
|
|
if inner.Unwrap() == nil {
|
|
break L
|
|
}
|
|
err = inner.Unwrap()
|
|
default:
|
|
break L
|
|
}
|
|
}
|
|
return err
|
|
}
|