Repository navigation
Conversation
A handler answering 500 for every error turns a bad cursor into a server bug, and one answering 400 for every ant error blames the client for a broken connection. Neither can read the 41 sentinels in errors.go. KindOf returns an ErrorKind: it reads the SQLSTATE code, then the sentinels a request can cause, and leaves everything else internal, so a new sentinel is a loud 500 until it is placed. A foreign key failure on a delete is a conflict and on a write invalid, and a lock timeout retries. Decision 177 records it and amends decision 45.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #343.
KindOfanswers anErrorKindfor an error, so an HTTP handler picks a status without knowing which of ant's 41 sentinels it got. It reads the driver's SQLSTATE where there is one, then the sentinels a request can cause, and leaves everything elseKindInternal: a new sentinel is a loud 500 until it is placed, not a quiet 400 that hides a bug.The order is the one in the plan: a canceled context, then the statement's SQLSTATE, then
ErrNotFound,ErrConcurrency,ErrCursorandErrPagingand anyValidationError. A foreign key failure goes by the statement —KindInvalidon a write,KindConflicton a delete, andKindConflictwhen there is no statement to tell. A lock timeout retries with the deadlocks. The kinds are seven-wide, small enough for a switch, and decision 177 records them and amends 45.Tests:
ANT_TEST_DATABASES=postgres go test ./tests/... .passes,make linthas 0 issues. Three mutations —23505to unavailable, theErrNotFoundbranch removed, the delete check removed — each turn the suite red. Only PostgreSQL ran; the fixture'spostsforeign key cascades, so the delete test rebuilds it without a cascade first.