@scienceai/create-error
v3.1.1
Published
Create an instance of Error with a code property mostly from various CouchDB responses
Downloads
5
Readme
create-error
Create an error with a code property
import createError from '@scienceai/create-error';
createError();
createError(404);
createError('not found');
createError(404, 'not found');
Automatically handle CouchDB and API responses (from request or XHR)
import createError from '@scienceai/create-error';
import request from 'request';
request('http://example.com/couchdb', (err, resp, body) => {
if (err = createError(err, resp, body)) {
return callback(err);
}
// no error, we can process body
});