Skip to content

Instantly share code, notes, and snippets.

@arcdev1
Created February 14, 2018 15:45
Show Gist options
  • Save arcdev1/f0cb57db538bd61328ecba3f689381ca to your computer and use it in GitHub Desktop.
Save arcdev1/f0cb57db538bd61328ecba3f689381ca to your computer and use it in GitHub Desktop.
function requiredParam (param) {
const requiredParamError = new Error(
`Required parameter, "${param}" is missing.`
)
// preserve original stack trace
if (typeof Error.captureStackTrace === ‘function’) {
Error.captureStackTrace(
requiredParamError,
requiredParam
)
}
throw requiredParamError
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment