Skip to content

Instantly share code, notes, and snippets.

@mrister
Last active August 16, 2016 15:22
Show Gist options
  • Save mrister/43154f7081836085c2e667565cf085a7 to your computer and use it in GitHub Desktop.
Save mrister/43154f7081836085c2e667565cf085a7 to your computer and use it in GitHub Desktop.
WError example
const VError = require('verror').VError;
const WError = require('verror').WError;
const errReqFail = new Error('Request failed');
const errReqStatus = new VError(errReqFail, 'Unexpected status code "%s"', '500');
const errReq = new WError(errReqStatus, 'Internal error');
console.error(errReq.message); //Internal error:
// get some real data for logging
console.info(errReq.toString()); //WError: Internal error; caused by VError: Unexpected status code "500": Request failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment