1
0
mirror of https://github.com/matt-fidd/stratos.git synced 2026-01-01 22:59:28 +00:00

Added error page and handling

This commit is contained in:
2022-01-24 01:23:38 +00:00
parent 39185c3301
commit 7502c189a1
2 changed files with 24 additions and 0 deletions

12
app.js
View File

@@ -50,6 +50,18 @@ async function main() {
}
}));
// If the request gets to the bottom of the route stack, it doesn't
// have a defined route and therefore a HTTP status code 404 is sent
// and an error page shown
app.use((req, res, next) => {
res.status(404).render('error', {
code: 404,
msg: 'Page Not Found'
});
next();
});
// Start the server
app.listen(serverOptions.port, () => {
console.log(`Server listening on :${serverOptions.port}`);

12
views/pages/error.ejs Normal file
View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<%- include('../partials/head', { title: 'Stratos - Error' }) %>
</head>
<body>
<h1>Error</h1>
<span class='code'><%= code %></span>
<span class='msg'><%= msg %></span>
</body>
</html>