Skip to content

Instantly share code, notes, and snippets.

@mrister
Last active August 16, 2016 15:21
Show Gist options
  • Save mrister/479ddb8283bb8995f1248af6aac783c1 to your computer and use it in GitHub Desktop.
Save mrister/479ddb8283bb8995f1248af6aac783c1 to your computer and use it in GitHub Desktop.
Example VError usage
const VError = require('verror');
const errReqFail = new Error('Request failed');
const errReqStatus = new VError(errReqFail, 'Unexpected status code "%s"', '500');
const errReqBase = new VError(errReqStatus, 'Internal error');
console.error(errReqBase); //VError: Internal error: Unexpected status code "500": Request failed
// unwind to check cause
console.info(errReqBase.cause().message); //Unexpected status code "500": Request failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment