Skip to content

Commit

Permalink
Add an extra condition in WebRPCError.Is to check against target nil … (
Browse files Browse the repository at this point in the history
#54)

* Add an extra condition in WebRPCError.Is to check against target nil value

* Update errors.go.tmpl

Co-authored-by: Vojtech Vitek (golang.cz) <vojtech.vitek@gmail.com>

---------

Co-authored-by: Vojtech Vitek (golang.cz) <vojtech.vitek@gmail.com>
  • Loading branch information
alinz and VojtechVitek authored Mar 7, 2024
1 parent d6c77aa commit 348fb3c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions errors.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ func (e WebRPCError) Error() string {
}

func (e WebRPCError) Is(target error) bool {
if target == nil {
return false
}
if rpcErr, ok := target.(WebRPCError); ok {
return rpcErr.Code == e.Code
}
Expand Down

0 comments on commit 348fb3c

Please sign in to comment.