Skip to content

Feature: Throw proper errors #3380

Open
@shellscape

Description

@shellscape

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:

.catch((err) => {
assert(err instanceof Error)
assert(/timeout expired\s*/.test(err.message))
closeServer(done)
})

Documentation for error.code https://nodejs.org/docs/v22.14.0/api/errors.html#errorcode

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions