UNPKG

@dannybster/coco-the-bear-http-errors

Version:

A collection of error objects that represent http response objects for CoCo The Bear.

24 lines (18 loc) 413 B
const VError = require('verror'); function createError(name, status, msg, info, body, cause) { const error = new VError({ cause, info, name, }, msg); error.httpResponse = { body, status, }; return error; } function isHTTPErrorWithName(name, err) { return err.name === name; } module.exports.createError = createError; module.exports.isHTTPErrorWithName = isHTTPErrorWithName;