IsTemporaryOrUnspec is similar to IsTemporary except that it returns true if error does not have a Temporary() method. Basically, it assumes that errors are temporary by default compared to IsTemporary that assumes errors are permanent by default.
(err error)
| 31 | // errors are temporary by default compared to IsTemporary that assumes |
| 32 | // errors are permanent by default. |
| 33 | func IsTemporaryOrUnspec(err error) bool { |
| 34 | var temp TemporaryErr |
| 35 | if errors.As(err, &temp) { |
| 36 | return temp.Temporary() |
| 37 | } |
| 38 | return true |
| 39 | } |
| 40 | |
| 41 | // IsTemporary returns true whether the passed error object |
| 42 | // have a Temporary() method and it returns true. |