You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current modern practice for the Node ecosystem is to inherit from Error and use the .code property to distinguish between errors. node-postgres does not. Like many today, we experienced an issue with Supabase downtime. And so we've started to look at how we can make our error handling in certain scenarios more robust.
Here's an example of how we currently have to track/check for errors:
The error.code property is a string label that identifies the kind of error. error.code is the most stable way to identify an error. It will only change between major versions of Node.js. In contrast, error.message strings may change between any versions of Node.js.
At the least, it would be really nice to have canonical errors that we could easily look for and react to.
The text was updated successfully, but these errors were encountered:
Yup I dig the idea - interested in doing a PR? Only thing to note: if the database driver recieves an error from postgres directly it will have a .code on it already - that code comes from postgres. So in that case...you can use that code. I do see how the timeout errors and other things are hard to differentiate though!
Current modern practice for the Node ecosystem is to inherit from
Error
and use the.code
property to distinguish between errors. node-postgres does not. Like many today, we experienced an issue with Supabase downtime. And so we've started to look at how we can make our error handling in certain scenarios more robust.Here's an example of how we currently have to track/check for errors:
node-postgres/packages/pg/test/integration/client/connection-timeout-tests.js
Lines 82 to 86 in 7325807
Documentation for
error.code
https://nodejs.org/docs/v22.14.0/api/errors.html#errorcodeAt the least, it would be really nice to have canonical errors that we could easily look for and react to.
The text was updated successfully, but these errors were encountered: