Skip to content

Commit

Permalink
v1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
thalesfsp committed Feb 19, 2022
1 parent 9fc323f commit 544abde
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.2] - 2022-02-18
## [1.0.3] - 2022-02-18
### Added
- Tests covering `.Is`.`

### Changed
- `.Is` is on a pointer instead of value.

## [1.0.2] - 2022-02-18
### Added
- API info is only added to error message on `APIError`.

## [1.0.1] - 2022-02-18
Expand Down
2 changes: 1 addition & 1 deletion customerror.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (cE *CustomError) Unwrap() error {
// Is interface implementation ensures chain continuity. Treats `CustomError` as
// equivalent to `err`.
//nolint:errorlint
func (cE CustomError) Is(err error) bool {
func (cE *CustomError) Is(err error) bool {
return cE.Err == err
}

Expand Down
12 changes: 12 additions & 0 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,15 @@ func ExampleNew_options() {
// output:
// E1010: missing id (406 - Not Acceptable). Original Error: some error
}

// Demonstrates error chain. `errB` will wrap `errA` and will be considered the
// same by propagating the chain.
func ExampleNew_is() {
errA := NewMissingError("id")
errB := NewMissingError("name", WithError(errA))

fmt.Println(errors.Is(errB, errA))

// output:
// true
}

0 comments on commit 544abde

Please sign in to comment.