Repository navigation
fix: Support typed database exceptions. - #3047
Merged
SandPod merged 12 commits intoDec 12, 2024
Merged
Conversation
SandPod
force-pushed
the
support-typed-database-exceptions
branch
from
December 11, 2024 12:11
6fce9ef to
8520c46
Compare
SandPod
force-pushed
the
support-typed-database-exceptions
branch
from
December 11, 2024 12:26
8520c46 to
ab8c80d
Compare
SandPod
marked this pull request as ready for review
December 11, 2024 13:08
Contributor
Author
|
@lukehutch - Please have a look at this to ensure everything you need is included. |
hampuslavin
reviewed
Dec 11, 2024
SandPod
force-pushed
the
support-typed-database-exceptions
branch
from
December 11, 2024 16:30
8d75009 to
2757f9a
Compare
christerswahn
left a comment
Contributor
There was a problem hiding this comment.
This is a really great "maturity" improvement! :) Left some comments and discussion point!
Contributor
LGTM, other than the open comments. |
hampuslavin
approved these changes
Dec 12, 2024
hampuslavin
left a comment
Contributor
There was a problem hiding this comment.
Looks good on my end 👍
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Introduces a new database exception type called
DatabaseQueryExceptionthat contains information related to an exception that occurred during a database query.The fields exposed through the
DatabaseQueryExceptionclass have been minimized to contain what is most relevant to the user.Please provide feedback if any important field has been left out.
The
codefield, which is probably what most developers will add code to parse, would have been nice to have typed. But since codes are not shared between different database types, the field is simply a nullable String.This PR supersedes the original PR introduced here: #2546
Database exception abstract interfaces
New interfaces have been added that allow the framework to extend the interfaces in a backward-compatible way.
By using abstract interface class we reserve the right to extend the interface in the future and prevent code outside of the library to implement it.
An implementation of the interface has been added to the Postgres adapter. This continues to set the foundation for allowing other adapters in the future.
Additional fixes
Where applicable, all legacy tests were converted to be more precise in their type checking.
The last commit also contains a minor refactor to flatten out the if statements when catching exceptions in a database query.
Pre-launch Checklist
///), and made sure that the documentation follows the same style as other Serverpod documentation. I checked spelling and grammar.If you need help, consider asking for advice on the discussion board.
Breaking changes
None - the intention behind these changes is to be implemented in a backwards-compatible way.
New subtypes in the adapter have been added, but these should not interfere with logic that catches current exceptions.