Skip to content

Instantly share code, notes, and snippets.

@totallymike
Created May 17, 2012 03:36
Show Gist options
  • Save totallymike/2716049 to your computer and use it in GitHub Desktop.
Save totallymike/2716049 to your computer and use it in GitHub Desktop.
Fun With Errors
db.query(statement, function (err, res) {
if (err) {
throw new Error(err);
} else {
// Do normal stuff.
}
});
db.query(statement, function (err, res) {
if (err) {
var originalMessage = err.message;
err.message = [originalMessage, 'Query failed for some reason'];
err.modelState = modelState; /* Pretend we already made an object called modelState
that has useful data about the Model's state. */
throw(err);
} else {
//do the rest of your stuff.
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment