mirror of
https://github.com/matt-fidd/stratos.git
synced 2026-01-02 14:39:29 +00:00
Added error page and handling
This commit is contained in:
12
app.js
12
app.js
@@ -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
|
// Start the server
|
||||||
app.listen(serverOptions.port, () => {
|
app.listen(serverOptions.port, () => {
|
||||||
console.log(`Server listening on :${serverOptions.port}`);
|
console.log(`Server listening on :${serverOptions.port}`);
|
||||||
|
|||||||
12
views/pages/error.ejs
Normal file
12
views/pages/error.ejs
Normal 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>
|
||||||
Reference in New Issue
Block a user