Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DatabaseError class should be public #2340

Closed
garaboncias opened this issue Sep 10, 2020 · 4 comments
Closed

DatabaseError class should be public #2340

garaboncias opened this issue Sep 10, 2020 · 4 comments

Comments

@garaboncias
Copy link

We need to handle Database errors in higher level, and we wan't to check if error come from db, and in that case error code is a specific code. Please export DatabaseError class from node-postgres to able to achieve that.

// Current workaround but its hacky.
import { DatabaseError } from 'pg-protocol/dist/messages';

/** https://www.postgresql.org/docs/current/errcodes-appendix.html */
enum postgresErrorCodes {
    read_only_sql_transaction = '25006'
}

   if (error instanceof DatabaseError && error.code == postgresErrorCodes.read_only_sql_transaction) {
      // handle write modification tries
   }
tcarrio added a commit to tcarrio/node-postgres that referenced this issue Oct 4, 2020
- Updated root exports of 'pg-protocol' to include DatabaseError

Ref: brianc#2340
brianc pushed a commit that referenced this issue Oct 4, 2020
- Updated root exports of 'pg-protocol' to include DatabaseError

Ref: #2340
@tcarrio
Copy link
Contributor

tcarrio commented Oct 4, 2020

@garaboncias just a heads up, the fix for this was just merged. Keep an eye out for the next release 😁

@brianc
Copy link
Owner

brianc commented Oct 4, 2020 via email

@tcarrio
Copy link
Contributor

tcarrio commented Oct 4, 2020

Crazy fast @brianc . Thanks for updating us here too ❤️

@garaboncias
Copy link
Author

Thank you for your support and kindness!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants