node-postgres icon indicating copy to clipboard operation
node-postgres copied to clipboard

Parse error returned by client.query

Open deryl27 opened this issue 10 years ago • 2 comments

The format of the error is as follows { [error: must be superuser or have the same role to cancel queries running in other server processes] name: 'error', length: 14, severity: 'ERROR', code: '01', detail: undefined, routine: 'pg_cancel_backend' }

How do I get the error attribute to retrieve the actual message. ?? It is not a Json format and when I do Json.stringify(err), the error array is not present

deryl27 avatar Jun 10 '16 14:06 deryl27

The message is what you see there. it is 'must be superuser .... processes'. I suspect this is just another Error object so you can use err.message to retrieve that message.

joskuijpers avatar Jun 21 '16 14:06 joskuijpers

Yup @joskuijpers nailed it: error.message is what you're looking for

brianc avatar Jun 21 '16 14:06 brianc