update error handling
This commit is contained in:
parent
c2bb32dcf2
commit
1c84982232
2 changed files with 2 additions and 2 deletions
2
index.js
2
index.js
|
@ -514,12 +514,14 @@ app.use(function(req, res, next) {
|
|||
res.status(404).render(dir + "errors/404.ejs");
|
||||
});
|
||||
app.use(function(error, req, res, next) {
|
||||
console.log(error);
|
||||
res.status(500).render(dir + "errors/500.ejs", { error });
|
||||
});
|
||||
app.listen(port, () => {
|
||||
console.log(`Server started on port ${port}`);
|
||||
});
|
||||
app.on("error", error => {
|
||||
console.log(error)
|
||||
if (error.syscall !== "listen") {
|
||||
throw error;
|
||||
}
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
<h1 class="center warning">500 Internal Server Error</h1>
|
||||
<p class="center warning">An error has occurred on the server.</p>
|
||||
<% if (error) { %>
|
||||
<h2 class="center warning">Error message:</h2>
|
||||
<pre class="center warning"><%= error.message %></pre>
|
||||
<h2 class="center warning">Stack trace:</h2>
|
||||
<pre class="center warning"><%= error.stack %></pre>
|
||||
<% } %>
|
||||
|
|
Loading…
Reference in a new issue