Skip to content

Migrate error comparisons to errors.Is/errors.As - #1336

Draft
bobheadxi wants to merge 1 commit into
mainfrom
errors-is-as-migration-7f3a9c
Draft

bobheadxi wants to merge 1 commit into
mainfrom
errors-is-as-migration-7f3a9c

Conversation

@bobheadxi

Copy link
Copy Markdown
Member

This change migrates direct error comparisons and error type assertions to the
modern errors package idioms:

  • err == SentinelErr / err != SentinelErr -> errors.Is(err, SentinelErr) / !errors.Is(...)
    for sentinels such as sql.ErrNoRows, context.Canceled, context.DeadlineExceeded,
    http.ErrServerClosed, io.ErrUnexpectedEOF, os.ErrNotExist, etc.
  • Error type assertions and switch err.(type) classification -> errors.As.

Excluded by design: io.EOF comparisons (idiomatic in reader loops) and _test.go files.

This makes error checks robust to wrapped errors (fmt.Errorf("...: %w", err)).

Generated by a Sourcegraph batch change.

Created by Sourcegraph batch change robert/58006530-3ddc-4c11-ad42-8d8eed8bc63f.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant