vitaly-t/pg-monitor

Display more than just the error message and query

xehpuk opened this issue · 5 comments

Concretely, the error code would be nice.

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);
        }
    }
};

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}

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}`;
        }
    }
};

Hacky, but an easy fix. Thanks!

Yeah, a little, but safe enough 😄