Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into invalidateFormFields
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeGoodall committed Nov 24, 2023
2 parents 6dbd348 + c3da356 commit 4435b18
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 23 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ app.use('/', formWizard)

// file not found handler
app.use((req, res, next) => {
res.status(404).render('pages/file-not-found')
res.status(404).render('file-not-found')
})

// error handler
Expand All @@ -74,7 +74,7 @@ app.use((err, req, res, next) => {

// handle session expired
if (err.code === 'SESSION_TIMEOUT') {
err.template = 'pages/session-expired'
err.template = 'session-expired'
}

// handle errors with automatic redirects
Expand All @@ -84,7 +84,7 @@ app.use((err, req, res, next) => {

// show error page
err.status = err.status || 500
err.template = err.template || 'pages/error'
err.template = err.template || 'error'
res.status(err.status).render(err.template, { err })
})

Expand Down
20 changes: 20 additions & 0 deletions src/views/error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

{% from "govuk/components/button/macro.njk" import govukButton %}

{% set pageName = "Error" %}

{% extends "layouts/main.html" %}

{% block content %}
<h1 class="govuk-heading-xl">Error</h1>

<h2>{{err.code + " - " if err.code}}{{err.message}}</h2>
{%if err.stack %}
<pre>{{err.stack | safe}}</pre>
{% endif %}

{{ govukButton({
text: "Start again",
href: "/"
}) }}
{% endblock %}
15 changes: 15 additions & 0 deletions src/views/file-not-found.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

{% from "govuk/components/button/macro.njk" import govukButton %}

{% set pageName = "File not found" %}

{% extends "layouts/main.html" %}

{% block content %}
<h2>Error: File not found</h2>

{{ govukButton({
text: "Start again",
href: "/"
}) }}
{% endblock %}
20 changes: 0 additions & 20 deletions src/views/pages/error.html

This file was deleted.

Empty file.
22 changes: 22 additions & 0 deletions src/views/session-expired.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% extends "layouts/main.html" %}

{% from "govuk/components/button/macro.njk" import govukButton %}

{% set pageName = 'Session Expired: ' + serviceName %}

{% block content %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-xl">
Session Expired
</h1>
</div>
</div>

<form method="POST">
{{ govukButton({
text: "Start over",
href: "/"
}) }}
</form>
{% endblock %}

0 comments on commit 4435b18

Please sign in to comment.