Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix incorrect usage of errors.Is #3215

Merged
merged 1 commit into from
Jun 29, 2021
Merged

fix incorrect usage of errors.Is #3215

merged 1 commit into from
Jun 29, 2021

Conversation

marten-seemann
Copy link
Member

errors.Is is supposed to used for equality of errors, not for type assertions. That's what errors.As is there for.

cc @mvdan

@codecov
Copy link

codecov bot commented Jun 27, 2021

Codecov Report

Merging #3215 (dbb5178) into master (a887f8f) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3215      +/-   ##
==========================================
- Coverage   85.40%   85.38%   -0.02%     
==========================================
  Files         134      133       -1     
  Lines        9825     9804      -21     
==========================================
- Hits         8391     8371      -20     
- Misses       1060     1061       +1     
+ Partials      374      372       -2     
Impacted Files Coverage Δ
packet_unpacker.go 86.02% <ø> (-0.29%) ⬇️
client.go 79.37% <100.00%> (ø)
internal/qerr/errors_go116.go 100.00% <100.00%> (+16.67%) ⬆️
session.go 77.41% <100.00%> (-0.05%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a887f8f...dbb5178. Read the comment docs.

func (e *IdleTimeoutError) Is(target error) bool { return target == net.ErrClosed }
func (e *HandshakeTimeoutError) Is(target error) bool { return target == net.ErrClosed }
func (e *VersionNegotiationError) Is(target error) bool { return target == net.ErrClosed }
func (e *StatelessResetError) Is(target error) bool { return target == net.ErrClosed }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 not sure how I didn't catch the type assertions in the last review :)

session.go Outdated Show resolved Hide resolved
errors.Is is supposed to used for equality of errors, not for type
assertions. That's what errors.As is there for.
@marten-seemann marten-seemann merged commit afaaaf9 into master Jun 29, 2021
@marten-seemann marten-seemann deleted the fix-errors-is branch July 6, 2021 16:51
@aschmahmann aschmahmann mentioned this pull request Aug 23, 2021
62 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants