Adds a super flexible res.error() method to express that logs an error and sends the correct JSON response to the client.