Skip to content

Instantly share code, notes, and snippets.

@ashutoshpw
Last active July 27, 2020 22:09
Show Gist options
  • Save ashutoshpw/c15c540b61531db9daac6658825a300d to your computer and use it in GitHub Desktop.
Save ashutoshpw/c15c540b61531db9daac6658825a300d to your computer and use it in GitHub Desktop.
express-errors
// Place this after all the routes and middlewares
app.all("*", (req, res, next)=>{
return res.send("Route Doesn't exists");
})
app.get("/", (req, res, next) => {
// Throw and Error knowingly. Another example could be
// let x = null.split(",");
throw new Error('Something Wrong');
return res.send("Hello World");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment