2020-07-13 09:40:47 +00:00
|
|
|
# [errors](https://golang.org/pkg/errors/)
|
|
|
|
|
|
|
|
Wrap error:
|
|
|
|
|
|
|
|
```go
|
|
|
|
err := fmt.Errorf("Something wrong: %w", rootErr)
|
|
|
|
```
|
|
|
|
|
|
|
|
Unwrap error:
|
|
|
|
|
|
|
|
```go
|
|
|
|
rootErr := errors.Unwrap(err)
|
|
|
|
```
|
2022-06-28 09:59:29 +00:00
|
|
|
|
|
|
|
Compare error:
|
|
|
|
|
|
|
|
```go
|
|
|
|
// Don't
|
|
|
|
if err == CustomErr
|
|
|
|
|
|
|
|
// Do
|
|
|
|
if errors.Is(err, CustomErr)
|
|
|
|
```
|