Skip to content

Copy fields of ServerException across to DatabaseException - #2546

Closed
lukehutch wants to merge 2 commits into
serverpod:mainfrom
lukehutch:richer-db-exceptions
Closed

lukehutch wants to merge 2 commits into
serverpod:mainfrom
lukehutch:richer-db-exceptions

Conversation

@lukehutch

Copy link
Copy Markdown
Contributor

All of the context of a PgException (specifically, the context in its subclass, ServerException) is lost when only the message is preserved in a DatabaseException. This means that the user cannot be notified, for example, of the character offset of a syntax error, which can make debugging query errors very difficult (you basically have to print out the query on the server console, copy/paste it into a proper Postgres client UI, and see where the error is highlighted).

This change copies all the fields of ServerException across to DatabaseException in a backwards-compatible way.

I will leave it up to you to add some of this extra info to the error logs, so that Serverpod Insights can report more info on database errors.

Pre-launch Checklist

  • I read the Contribute page and followed the process outlined there for submitting PRs.
  • This update contains only one single feature or bug fix and nothing else. (If you are submitting multiple fixes, please make multiple PRs.)
  • I read and followed the Dart Style Guide and formatted the code with dart format.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///), and made sure that the documentation follows the same style as other Serverpod documentation. I checked spelling and grammar.
  • I added new tests to check the change I am making.
  • All existing and new tests are passing.
  • Any breaking changes are documented below.

@SandPod

SandPod commented Nov 11, 2024

Copy link
Copy Markdown
Contributor

@lukehutch - Would it be OK if I take this PR over and get it in?

@lukehutch

Copy link
Copy Markdown
Contributor Author

@SandPod please do

@github-actions github-actions Bot locked and limited conversation to collaborators Nov 27, 2024
@SandPod SandPod reopened this Nov 27, 2024
@SandPod

SandPod commented Nov 27, 2024

Copy link
Copy Markdown
Contributor

Sorry, the close here was not intentional. An incorrect reference to this PR accidentally closed the issue.

@serverpod serverpod unlocked this conversation Nov 27, 2024
@SandPod SandPod mentioned this pull request Dec 11, 2024
8 tasks done
@SandPod

SandPod commented Dec 12, 2024

Copy link
Copy Markdown
Contributor

This feature was implemented in: #3047

@SandPod SandPod closed this Dec 12, 2024
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants