Display more than just the error message and query
xehpuk opened this issue · 5 comments
xehpuk commented
Concretely, the error code would be nice.
vitaly-t commented
For that, use event error, and display anything you want.
const initOptions = {
error(err, e) {
// display the error code, if it is available:
if(err.code) {
console.log('ERR-CODE:', err.code);
}
}
};
xehpuk commented
Yeah, that's what I do as a workaround. But I'd like to have it inside the output of pg-monitor
, like:
error: {error.code} {error.message}
query: {query}
vitaly-t commented
I'd like to have it inside the output of
pg-monitor
You can add the code to the error message then:
const options = {
error(err, e) {
if (err.code) {
err.message = `${err.code} ${err.message}`;
}
}
};
xehpuk commented
Hacky, but an easy fix. Thanks!
vitaly-t commented
Yeah, a little, but safe enough 😄