Skip to content

Commit 52e084a

Browse files
authored
Override the error page so we can apply branding (#313)
The default error page uses the govuk branding (and not the unbranded version) and so we have no control over what it looks like. With previously installed packages, we get the wrong logo etc.
1 parent 44de788 commit 52e084a

File tree

4 files changed

+332
-112
lines changed

4 files changed

+332
-112
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{% extends "layouts/main.html" %}
2+
3+
{% block pageTitle %}
4+
Page not found – {{ serviceName }} – GOV.UK Prototype Kit
5+
{% endblock %}
6+
{% set mainClasses = "govuk-main-wrapper--l" %}
7+
8+
{% block content %}
9+
10+
<div class="govuk-grid-row">
11+
<div class="govuk-grid-column-two-thirds">
12+
13+
<h1 class="govuk-heading-l">Page not found</h1>
14+
<p class="govuk-body">
15+
There is no page at <strong>{{ path }}</strong>
16+
</p>
17+
<p class="govuk-body">This may be because:</p>
18+
<ul class="govuk-list govuk-list--bullet">
19+
<li>you typed or pasted the web address incorrectly</li>
20+
<li>a link in your code is wrong</li>
21+
<li>a form in your code is wrong</li>
22+
<li>you have not created the page yet</li>
23+
</ul>
24+
<p class="govuk-body">
25+
You can try and fix this yourself or <a class="govuk-link" href="https://www.register-dynamics.co.uk/contacts">contact the Register Dynamics team</a> if you need help.
26+
</p>
27+
</div>
28+
</div>
29+
{% endblock %}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{% extends "layouts/main.html" %}
2+
3+
{% block pageTitle %}
4+
Error {% if serviceName %}{{ serviceName }}{% endif %} – GOV.UK Prototype Kit
5+
{% endblock %}
6+
7+
{% block content %}
8+
9+
<div class="govuk-grid-row">
10+
<div class="govuk-grid-column-full">
11+
<h1 class="govuk-heading-l">There is an error</h1>
12+
13+
{% if error.filePath %}
14+
<p class="govuk-prototype-kit-error-info">
15+
<strong>File:</strong> <span id="govuk-prototype-kit-error-file">{{ error.filePath }} {% if error.line %}(line {{ error.line }}){% endif %}</span>
16+
</p>
17+
{% endif %}
18+
19+
<p class="govuk-prototype-kit-error-info">
20+
<strong>Error:</strong> <span id="govuk-prototype-kit-error-message">{{ error.message }}</span>
21+
</p>
22+
23+
{% if error.sourceCode %}
24+
<pre tabindex="0" class="govuk-prototype-kit-error-code govuk-!-margin-bottom-5" id="govuk-prototype-kit-error-block"><code>{{ error.sourceCode.before }}</code><br><code id="govuk-prototype-kit-error-line">{{ error.sourceCode.error }}</code><br><code>{{ error.sourceCode.after }}</code></pre>
25+
{% endif %}
26+
27+
<div id="govuk-prototype-kit-show-error-button-container" hidden>
28+
<button id="govuk-prototype-kit-show-error-button" class="govuk-button govuk-button--secondary govuk-!-margin-bottom-1" data-module="govuk-button" aria-expanded="false" aria-controls="govuk-prototype-kit-error-stack">
29+
Show full error
30+
</button>
31+
</div>
32+
33+
<pre tabindex="0" id="govuk-prototype-kit-error-stack" class="govuk-prototype-kit-error-code js-hidden"><code>{{ error.errorStack }}</code></pre>
34+
35+
<p class="govuk-body govuk-!-margin-top-5">
36+
<a class="govuk-link" href="https://www.register-dynamics.co.uk/contact">Get support</a>
37+
</p>
38+
39+
</div>
40+
</div>
41+
42+
43+
{% endblock %}
44+
45+
46+
{% block footer %}
47+
{{ govukFooter({}) }}
48+
{% endblock %}
49+
50+
51+
{% block pageScripts %}
52+
<script>
53+
;(() => {
54+
const toggleErrorStack = (event) => {
55+
const button = event.target
56+
const isExpanded = button.getAttribute('aria-expanded') === 'true'
57+
const newState = isExpanded ? 'false' : 'true'
58+
const newText = isExpanded ? 'Show full error' : 'Hide full error'
59+
button.setAttribute('aria-expanded', newState)
60+
button.textContent = newText
61+
62+
const element = document.getElementById('govuk-prototype-kit-error-stack')
63+
element.classList.toggle('js-hidden')
64+
}
65+
66+
document.getElementById('govuk-prototype-kit-show-error-button-container').hidden = false
67+
68+
document.getElementById('govuk-prototype-kit-show-error-button')
69+
.addEventListener('click', toggleErrorStack)
70+
})()
71+
</script>
72+
{% endblock %}

0 commit comments

Comments
 (0)