update error handling

This commit is contained in:
Firepup Sixfifty 2025-01-30 11:12:20 -06:00
parent c2bb32dcf2
commit 1c84982232
Signed by: Firepup650
SSH key fingerprint: SHA256:cb8sEJwc0kQJ6/nMUhscWRe35itf0NFMdSKl3v4qt48
2 changed files with 2 additions and 2 deletions

View file

@ -514,12 +514,14 @@ app.use(function(req, res, next) {
res.status(404).render(dir + "errors/404.ejs"); res.status(404).render(dir + "errors/404.ejs");
}); });
app.use(function(error, req, res, next) { app.use(function(error, req, res, next) {
console.log(error);
res.status(500).render(dir + "errors/500.ejs", { error }); res.status(500).render(dir + "errors/500.ejs", { error });
}); });
app.listen(port, () => { app.listen(port, () => {
console.log(`Server started on port ${port}`); console.log(`Server started on port ${port}`);
}); });
app.on("error", error => { app.on("error", error => {
console.log(error)
if (error.syscall !== "listen") { if (error.syscall !== "listen") {
throw error; throw error;
} }

View file

@ -14,8 +14,6 @@
<h1 class="center warning">500 Internal Server Error</h1> <h1 class="center warning">500 Internal Server Error</h1>
<p class="center warning">An error has occurred on the server.</p> <p class="center warning">An error has occurred on the server.</p>
<% if (error) { %> <% if (error) { %>
<h2 class="center warning">Error message:</h2>
<pre class="center warning"><%= error.message %></pre>
<h2 class="center warning">Stack trace:</h2> <h2 class="center warning">Stack trace:</h2>
<pre class="center warning"><%= error.stack %></pre> <pre class="center warning"><%= error.stack %></pre>
<% } %> <% } %>