Error handler middleware for kwest module. Rejects responses with bad statuscodes.
$ npm install --save kwest-handle-error
without errorHandler
var request = require('kwest-base');
request('http://www.example.com/not-found')
.then(function (res) {
console.log(res.statusCode); // 404
});
with errorHandler
var handleError = require('kwest-handle-error'),
kwest = require('kwest-base'),
request = kwest.wrap(handleError());
request('http://www.example.com/not-found')
.catch(function (err) {
console.log(err.message); // "404: Not found"
});