omsmith/ims-lti — pull request #17 by Tape (2014-08-22 17:16:15+00:00)
Title: Implement error classes

This is just a concept to make error handling a little better, I personally like the way Bluebird handles their errors. This allows you to do something like so. Without Bluebird you can simply do an instanceof check on the err passed into the callback.

```js
var promise = require("bluebird");
var lti = require("ims-lti");

var provider = new lti.Provider(myKey, mySecret, myStore);
var isValid = Promise.promisify(provider.valid_request, provider);

isValid(req).then(function () {
return commitToSession();
})
.catch(lti.errors.ParameterError, function () {
res.redirect(302, req.post.launch_presentation_return_url);
})
.catch(lti.errors.SignatureError, function () {
res.render("errors/configuration");
})
.catch(function () {
res.render("errors/internal");
});

```