mattn / mattn/go-sqlite3

Implement Error.Is() method

Open
#949 6 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
9.2k
Forks
1.2k
Avg merge
19m
Merged PRs (30d)
4

Description

Go 1.13 introduced wrapped errors, as well as errors.Is(x, y), which will automatically unwrap errors and either do a comparison, or check to see if an error's Is() method returns true. This would basically be:

func (err Error) Is(target Error) bool {
		switch v := target.(type) {
		case ErrNo:
			return err.Code == v
		case ErrNoExtended:
			return err.ExtendedCode == v
		}
		return false
}

Then errors.Is(err, sqlite3.ErrConstraint) should work as expected.

I can send a PR in a couple of weeks if nobody objects and/or nobody gets around to it.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Error, ErrNo, and ErrNoExtended definitions in the go-sqlite3 repository and review how errors are currently represented. Verify that errors.Is(err, sqlite3.ErrConstraint) works for the relevant error codes, including wrapped errors, and confirm the existing error behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sqlite
Domain
databases
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.