lib-error-wrapper
v1.0.2
Published
A library to wrap other libraries that throw request-promise errors. Cleans up error output.
Downloads
4
Readme
lib-error-wrapper
A library to wrap other libraries that throw request-promise errors. Cleans up error output.
Usage
const errorWrapper = require('lib-error-wrapper');
const something = errorWrapper(require('something'));
something.action().catch(err => {
// If error was a request-promise StatusCodeError, err will be a cleaned up version
});
Will only transform errors with name: 'StatusCodeError'
, all others will be thrown as received.
options.fields
Wrap your target library passing { fields: ['name'] }
as options to include the name
field from the original error on the transformed error:
const something = errorWrapper(require('something'), { fields: ['name'] });
options.raw
Use this options to skip all transformations and throw the error as it was received.
Updating this NPM package
- Commit changes and merge to
master
. - Update the
CHANGELOG.md
with version number and notes on changes since the last version. - Make sure you are logged in to npm on the CLI:
npm login
. - Run
npm version <update_type>
.update_type
is one of the semantic versioning release types: "patch","minor", or "major".- This will update the
package.json
and tag the git repo.
- Commit and push versioning update and tags.
- Run
npm publish
. - Visit https://www.npmjs.com/package/lib-error-wrapper and ensure the correct version is displayed.
Futher reading:
NPM docs: Updating the package - https://docs.npmjs.com/getting-started/publishing-npm-packages#updating-the-package