Last active
August 16, 2016 15:21
-
-
Save mrister/479ddb8283bb8995f1248af6aac783c1 to your computer and use it in GitHub Desktop.
Example VError usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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