Created
May 17, 2012 03:36
-
-
Save totallymike/2716049 to your computer and use it in GitHub Desktop.
Fun With Errors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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