Description
Hi,
Firstly, thanks for node-postgres - a lot of our projects use Postgres and node-postgres provides a great bridge to Node.
The database errors I've come across in node-postgres (either returned in callbacks or emitted via 'error' events) are all object literals and not Error instances. This means they don't have stack information and can't be handled by default software error handlers. These software handlers include the default node handler and the Express default handler. The former produces an "Uncaught, unspecified 'error' event." (see issue #41) and the latter just emits an 'undefined' error rather than producing a nice stack trace.
It would be great to have node-postgres emit database errors that are at instances of (or subclasses of) the builtin Error class, such that the following holds true:
client.query(
'BAD SQL: RETURN AN ERROR',
function (err, result) {
assert.ok(err instanceof Error);
}
);