sing/common/exceptions/inner.go
2022-07-06 21:15:32 +08:00

20 lines
266 B
Go

package exceptions
type HasInnerError interface {
Unwrap() error
}
func Unwrap(err error) error {
for {
inner, ok := err.(HasInnerError)
if !ok {
break
}
innerErr := inner.Unwrap()
if innerErr == nil {
break
}
err = innerErr
}
return err
}