-
Notifications
You must be signed in to change notification settings - Fork 1
/
error.njk
62 lines (55 loc) · 1.17 KB
/
error.njk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
---
title: Oh wow, this is awkward.
layout: layouts/default.njk
---
{% block styles %}
<style>
.x {
display: grid;
min-height: 100dvh;
place-items: center;
}
</style>
{% endblock %}
<div class="x">
<h1>{{ title }}</h1>
<p><span id="message"></span>maybe try the <a href="/">home page</a>.</p>
</div>
{% block scripts %}
<script>
/**
* @var {HTMLElement | null} elMessage
*/
const elMessage = document.querySelector('#message');
/**
* @var {URLSearchParams} params
*/
const params = (new URL(document.location)).searchParams;
/**
* Set the message and applies it to the DOM
*
* @return {void}
*/
const setErrorMessage = () => {
if(!elMessage) {
return;
}
let message = '';
const error = params?.get("error");
switch(error) {
case '401':
case '403':
message = 'You are not authorised to see this content… ';
break;
case '500':
message = 'An unexpected server error occurred… ';
break;
default:
case '404':
message = 'Whatever it was you were looking for, could not be found… ';
}
elMessage.innerText = message;
}
setErrorMessage();
</script>
{% endblock %}