Skip to content

DatabaseError class should be public #2340

@garaboncias

Description

@garaboncias

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
   }

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