handle-http-error
Version:
Handle a few common cases when an HTTP request got an error.
20 lines (16 loc) • 337 B
JavaScript
;
const notObjectOrIsEmpty = require('not-empty-object').notObjectOrIsEmpty;
module.exports = isErrorObj;
/**
* .
*/
function isErrorObj(val) {
if (notObjectOrIsEmpty(val)) {
return false;
}
const type = typeof val.message;
if (type === 'string' || type === 'number') {
return val;
}
return false;
}