Skip to content

Conversation

@KristjanTammekivi
Copy link

Previously I've used a hack to override the error constructor but I feel like it's time to implement it directly in pg-protocol.

Features added:

  • condition property on errors
  • exported POSTGRES_ERROR_CODES and POSTGRES_ERRORS_BY_CODE (so it's easier to do stuff like if (error.code === POSTGRES_ERROR_CODES.UNIQUE_VIOLATION))
  • added a script to generate the aforementioned dictionaries
  • added a tighter typing on postgres error code

@matthieusieben
Copy link
Contributor

You should make this optional, for example by using another package:

const { getPgErrorCondition } = require('pg-error-details')

const condition = getPgErrorCondition(pgErr)

@KristjanTammekivi
Copy link
Author

You should make this optional, for example by using another package:

const { getPgErrorCondition } = require('pg-error-details')

const condition = getPgErrorCondition(pgErr)

Well, it's just a new property on the error so I'd say it's optional

@matthieusieben
Copy link
Contributor

matthieusieben commented Sep 29, 2021

The 20kb addition to the package size are not really optional :/

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

Successfully merging this pull request may close these issues.

2 participants