diff --git a/assets/views/errors/400.njk b/assets/views/errors/400.njk deleted file mode 100644 index aa8e1f7..0000000 --- a/assets/views/errors/400.njk +++ /dev/null @@ -1,2 +0,0 @@ -{% extends 'errors/error.njk' %} -{% import 'macros.njk' as macros %} diff --git a/assets/views/errors/400.svelte b/assets/views/errors/400.svelte new file mode 100644 index 0000000..5ad9f17 --- /dev/null +++ b/assets/views/errors/400.svelte @@ -0,0 +1,5 @@ + + + diff --git a/assets/views/errors/401.njk b/assets/views/errors/401.njk deleted file mode 100644 index aa8e1f7..0000000 --- a/assets/views/errors/401.njk +++ /dev/null @@ -1,2 +0,0 @@ -{% extends 'errors/error.njk' %} -{% import 'macros.njk' as macros %} diff --git a/assets/views/errors/401.svelte b/assets/views/errors/401.svelte new file mode 100644 index 0000000..a6d9d83 --- /dev/null +++ b/assets/views/errors/401.svelte @@ -0,0 +1,5 @@ + + + diff --git a/assets/views/errors/403.njk b/assets/views/errors/403.njk deleted file mode 100644 index aa8e1f7..0000000 --- a/assets/views/errors/403.njk +++ /dev/null @@ -1,2 +0,0 @@ -{% extends 'errors/error.njk' %} -{% import 'macros.njk' as macros %} diff --git a/assets/views/errors/403.svelte b/assets/views/errors/403.svelte new file mode 100644 index 0000000..98a397f --- /dev/null +++ b/assets/views/errors/403.svelte @@ -0,0 +1,5 @@ + + + diff --git a/assets/views/errors/404.njk b/assets/views/errors/404.njk deleted file mode 100644 index aa8e1f7..0000000 --- a/assets/views/errors/404.njk +++ /dev/null @@ -1,2 +0,0 @@ -{% extends 'errors/error.njk' %} -{% import 'macros.njk' as macros %} diff --git a/assets/views/errors/404.svelte b/assets/views/errors/404.svelte new file mode 100644 index 0000000..69c414d --- /dev/null +++ b/assets/views/errors/404.svelte @@ -0,0 +1,5 @@ + + + diff --git a/assets/views/errors/429.njk b/assets/views/errors/429.njk deleted file mode 100644 index aa8e1f7..0000000 --- a/assets/views/errors/429.njk +++ /dev/null @@ -1,2 +0,0 @@ -{% extends 'errors/error.njk' %} -{% import 'macros.njk' as macros %} diff --git a/assets/views/errors/429.svelte b/assets/views/errors/429.svelte new file mode 100644 index 0000000..cd0e471 --- /dev/null +++ b/assets/views/errors/429.svelte @@ -0,0 +1,5 @@ + + + diff --git a/assets/views/errors/500.njk b/assets/views/errors/500.njk deleted file mode 100644 index aa8e1f7..0000000 --- a/assets/views/errors/500.njk +++ /dev/null @@ -1,2 +0,0 @@ -{% extends 'errors/error.njk' %} -{% import 'macros.njk' as macros %} diff --git a/assets/views/errors/500.svelte b/assets/views/errors/500.svelte new file mode 100644 index 0000000..4682025 --- /dev/null +++ b/assets/views/errors/500.svelte @@ -0,0 +1,5 @@ + + + diff --git a/assets/views/errors/503.njk b/assets/views/errors/503.njk deleted file mode 100644 index aa8e1f7..0000000 --- a/assets/views/errors/503.njk +++ /dev/null @@ -1,2 +0,0 @@ -{% extends 'errors/error.njk' %} -{% import 'macros.njk' as macros %} diff --git a/assets/views/errors/503.svelte b/assets/views/errors/503.svelte new file mode 100644 index 0000000..47e7f5b --- /dev/null +++ b/assets/views/errors/503.svelte @@ -0,0 +1,5 @@ + + + diff --git a/assets/views/errors/Error.svelte b/assets/views/errors/Error.svelte new file mode 100644 index 0000000..e6f67ce --- /dev/null +++ b/assets/views/errors/Error.svelte @@ -0,0 +1,47 @@ + + + + {code + ' - ' + message} + + + + + +
+ + +
{code}
+
{message}
+ {#if instructions} +
{@html instructions}
+ {/if} + + +
+ +
+

Error ID: {$locals.error_id || 'Request has no indentifier.'}

+

+ If you think this isn't right, please contact us with the above error ID at + {$locals.app.contact_email}. +

+
diff --git a/assets/views/errors/error.njk b/assets/views/errors/error.njk deleted file mode 100644 index 86a1c77..0000000 --- a/assets/views/errors/error.njk +++ /dev/null @@ -1,37 +0,0 @@ -{% extends 'layouts/barebone.njk' %} - -{% set title = error_code + ' - ' + error_message %} - -{% block _stylesheets %} - -{% endblock %} - -{% block _body %} - - -
- {% if flash %} - {{ macros.messages(flash) }} - {% endif %} - -
{{ error_code }}
-
{{ error_message }}
-
{{ error_instructions|safe }}
- - -
- -
- Error ID: {{ error_id | default('Request has no indentifier.') }} -
- If you think this isn't right, please contact us with the above error ID at - {{ app.contact_email }}. -
-{% endblock %} \ No newline at end of file diff --git a/src/Application.ts b/src/Application.ts index 3f41f07..8c0aa51 100644 --- a/src/Application.ts +++ b/src/Application.ts @@ -182,11 +182,18 @@ export default abstract class Application implements Extendable { - res.render('errors/' + httpError.errorCode + '.njk', { + const locals = { error_code: httpError.errorCode, error_message: httpError.message, error_instructions: httpError.instructions, error_id: errorId, + }; + res.render('errors/' + httpError.errorCode, locals, (err: Error | undefined, html) => { + if (err) { + res.render('errors/Error', locals); + } else { + res.send(html); + } }); }, json: () => {