Skip to content

Instantly share code, notes, and snippets.

@mxriverlynn
Created May 15, 2016 22:00
Show Gist options
  • Save mxriverlynn/c69096c7970ba18ecc3d09969b098f3d to your computer and use it in GitHub Desktop.
Save mxriverlynn/c69096c7970ba18ecc3d09969b098f3d to your computer and use it in GitHub Desktop.
custom error with clean stack trace
function createError(msg, status){
var err = new Error(msg);
err.status = status;
// uncomment this next line to get a clean stack trace in node.js
// Error.captureStackTrace(err, createError);
return err;
}
var err = createError("test", 500);
throw err;
@Knighton910
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment