Currently sql-pg throws some own errors, like the .one() selection method. But it's not handy to catch them with the error message. So it would be good to provide an error code also and provide all error codes in the sql object as constants.
So something like this would be possible:
try {
const user = sql.one('users', { email: req.body.email })
} catch (e) {
if (e.code === sql.NO_ROW_ERROR) {
res.status(403).send('incorrect email')
return
} else {
res.sendStatus(500)
}
}