Closed
Conversation
We now format them like psql, e.g.:
pq: syntax error at or near "FROM"
LINE 1: SELECT * FROM FROM items;
^
Closes lib#194
Closed
arp242
added a commit
that referenced
this pull request
Jan 3, 2026
…rors
Add a new ErrorWithDetail() method which also prints the Detail, Hint,
and query position (if any). For example:
ERROR: unacceptable schema name "pg_xx" (42939)
DETAIL: The prefix "pg_" is reserved for system schemas.
Or if the Position is set and we have a query, or prints up to three
lines of context with a ^ to mark the position:
ERROR: invalid input syntax for type json (22P02)
DETAIL: Token "asd" is invalid.
CONTEXT: line 5, column 8:
3 | 'def',
4 | 123,
5 | 'foo', 'asd'::jsonb
^
The format is based on what psql prints on errors (though not exactly
identical).
Based on the code I wrote for toml a few years ago:
https://github.com/BurntSushi/toml/blob/master/error.go
The regular error message now also includes the error code:
pq: syntax error at end of input (42601)
psql doesn't print them, but I've found it useful on a number of
occasion, and I think in the context of a library like this it probably
makes sense.
Fixes #194
Fixes #521
Fixes #679
Fixes #895
arp242
added a commit
that referenced
this pull request
Jan 3, 2026
Add a new ErrorWithDetail() method which also prints the Detail, Hint,
and query position (if any). For example:
ERROR: unacceptable schema name "pg_xx" (42939)
DETAIL: The prefix "pg_" is reserved for system schemas.
Or if the Position is set and we have a query, or prints up to three
lines of context with a ^ to mark the position:
ERROR: invalid input syntax for type json (22P02)
DETAIL: Token "asd" is invalid.
CONTEXT: line 5, column 8:
3 | 'def',
4 | 123,
5 | 'foo', 'asd'::jsonb
^
The format is based on what psql prints on errors (though not exactly
identical).
Based on the code I wrote for toml a few years ago:
https://github.com/BurntSushi/toml/blob/master/error.go
The regular error message now also includes the error code:
pq: syntax error at end of input (42601)
psql doesn't print them, but I've found it useful on a number of
occasion, and I think in the context of a library like this it probably
makes sense.
Fixes #194
Fixes #521
Fixes #679
Fixes #895
arp242
added a commit
that referenced
this pull request
Jan 3, 2026
Add a new ErrorWithDetail() method which also prints the Detail, Hint,
and query position (if any). For example:
ERROR: unacceptable schema name "pg_xx" (42939)
DETAIL: The prefix "pg_" is reserved for system schemas.
Or if the Position is set and we have a query, or prints up to three
lines of context with a ^ to mark the position:
ERROR: invalid input syntax for type json (22P02)
DETAIL: Token "asd" is invalid.
CONTEXT: line 5, column 8:
3 | 'def',
4 | 123,
5 | 'foo', 'asd'::jsonb
^
The format is based on what psql prints on errors (though not exactly
identical).
Based on the code I wrote for toml a few years ago:
https://github.com/BurntSushi/toml/blob/master/error.go
The regular error message now also includes the error code:
pq: syntax error at end of input (42601)
psql doesn't print them, but I've found it useful on a number of
occasion, and I think in the context of a library like this it probably
makes sense.
Fixes #194
Fixes #521
Fixes #679
Fixes #895
arp242
added a commit
that referenced
this pull request
Jan 3, 2026
Add a new ErrorWithDetail() method which also prints the Detail, Hint,
and query position (if any). For example:
ERROR: unacceptable schema name "pg_xx" (42939)
DETAIL: The prefix "pg_" is reserved for system schemas.
Or if the Position is set and we have a query, or prints up to three
lines of context with a ^ to mark the position:
ERROR: invalid input syntax for type json (22P02)
DETAIL: Token "asd" is invalid.
CONTEXT: line 5, column 8:
3 | 'def',
4 | 123,
5 | 'foo', 'asd'::jsonb
^
The format is based on what psql prints on errors (though not exactly
identical).
Based on the code I wrote for toml a few years ago:
https://github.com/BurntSushi/toml/blob/master/error.go
The regular error message now also includes the error code:
pq: syntax error at end of input (42601)
psql doesn't print them, but I've found it useful on a number of
occasion, and I think in the context of a library like this it probably
makes sense.
Fixes #194
Fixes #521
Fixes #679
Fixes #895
Collaborator
|
Fixed via #1219 |
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.
We now format them like psql, e.g.:
Fixes #194
Fixes #679