github.com/kunlun-qilian/sqlx/v3@v3.0.0/util.go (about) 1 package sqlx 2 3 func UnwrapAll(err error) error { 4 for { 5 if cause := UnwrapOnce(err); cause != nil { 6 err = cause 7 continue 8 } 9 break 10 } 11 return err 12 } 13 14 func UnwrapOnce(err error) (cause error) { 15 switch e := err.(type) { 16 case interface{ Cause() error }: 17 return e.Cause() 18 case interface{ Unwrap() error }: 19 return e.Unwrap() 20 } 21 return nil 22 }