Skip to content

Add Detail to Error()#842

Closed
dbresson wants to merge 1 commit intolib:masterfrom
dbresson:feature/add-Detail-to-Error
Closed

Add Detail to Error()#842
dbresson wants to merge 1 commit intolib:masterfrom
dbresson:feature/add-Detail-to-Error

Conversation

@dbresson
Copy link
Copy Markdown

Resolves #679

@dbresson dbresson force-pushed the feature/add-Detail-to-Error branch from 7f84dcc to 37affdb Compare March 29, 2019 19:26
Copy link
Copy Markdown

@andriikushch andriikushch left a comment

Choose a reason for hiding this comment

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

Looks good and reasonable to me.

@dbresson dbresson force-pushed the feature/add-Detail-to-Error branch from 37affdb to b3a2eaf Compare March 11, 2021 16:10
@dbresson dbresson force-pushed the feature/add-Detail-to-Error branch from b3a2eaf to 7a80be2 Compare April 1, 2022 18:37
@arp242
Copy link
Copy Markdown
Collaborator

arp242 commented Jan 3, 2026

PostgreSQL assumes it's printed on a separate line:

(0)=# create schema pg_xxx;
ERROR:  unacceptable schema name "pg_xxx"
DETAIL:  The prefix "pg_" is reserved for system schemas.

I think the "detail" looks quite ugly like this:

pq: unacceptable schema name "pg_xx": The prefix "pg_" is reserved for system schemas.

This is a relatively simple message, but some are quite long.

What I'll do is rewrite #521 to provide more detailed messages via ErrorDetailed() something, leaving the regular Error() method as it is now.

@arp242 arp242 closed this Jan 3, 2026
@dbresson
Copy link
Copy Markdown
Author

dbresson commented Jan 3, 2026

@arp242 The whole point was to include the necessary detail in Error() because some of the errors are completely useless without that detail.

It seems pretty silly to prioritize cosmetics over utility in an error message.

@arp242
Copy link
Copy Markdown
Collaborator

arp242 commented Jan 3, 2026

I had a look at the PostgreSQL source, and most errors did not seem appropriate to add to the Error() string. But we can make some selected exceptions for some errors, maybe.

@dbresson
Copy link
Copy Markdown
Author

dbresson commented Jan 3, 2026

Doing so selectively would be a reasonable solution.

Too bad I didn't include the specific error that prompted me to open the ticket as an example of why.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Detail to Error()

3 participants