Miss any of our Open RFC calls?Watch the recordings here! »

kwest-handle-error

0.1.0 • Public • Published

kwest-handle-error Build Status Dependency Status

Error handler middleware for kwest module. Rejects responses with bad statuscodes.

Installation

$ npm install --save kwest-handle-error

Use

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"
  });

Keywords

Install

npm i kwest-handle-error

DownloadsWeekly Downloads

2

Version

0.1.0

License

MIT

Last publish

Collaborators

  • avatar