Skip to content

Instantly share code, notes, and snippets.

@Noitidart
Created February 23, 2018 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Noitidart/bbd6c2b52ae78e2d3befdcba5dd542c3 to your computer and use it in GitHub Desktop.
Save Noitidart/bbd6c2b52ae78e2d3befdcba5dd542c3 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
}
function doit({ rawr=requiredParam('rawr'), foo=requiredParam()}) { return 'yep' }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment