-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace 404 page with general error page
- Loading branch information
1 parent
7f2cf1b
commit f2504d8
Showing
4 changed files
with
121 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<script lang="ts"> | ||
export let error: Error; | ||
const goBack = () => { | ||
history.back(); | ||
return false; | ||
}; | ||
</script> | ||
|
||
<main> | ||
<h1>An unexpected error occurred</h1> | ||
<p>The following error has occurred:</p> | ||
<code>{error.toString()}</code> | ||
{#if error.stack} | ||
{#each error.stack.split("\n") as line} | ||
<code>{line}</code> | ||
{/each} | ||
{/if} | ||
<p> | ||
Try <a href={document.referrer} on:click={goBack}>going back</a>, if | ||
that doesn't help, | ||
<a href="https://github.com/keombre/progtest-theme/issues" | ||
>file an issue on GitHub</a | ||
>. | ||
</p> | ||
</main> | ||
|
||
<style> | ||
code { | ||
display: block; | ||
} | ||
main { | ||
font-size: 14px; | ||
max-width: 640px; | ||
margin: 0 auto; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Page } from "../Page"; | ||
import ErrorComponent from "./Error.svelte"; | ||
|
||
export class ErrorPage implements Page { | ||
constructor(private error: Error) {} | ||
|
||
async initialise() { | ||
document.title = "Error | ProgTest"; | ||
|
||
const center = document.querySelector<HTMLElement>("body > center"); | ||
if (center) { | ||
center.style.display = "none"; | ||
} | ||
|
||
const container = document.createElement("div"); | ||
document.body.insertBefore(container, center); | ||
new ErrorComponent({ | ||
target: container, | ||
props: { error: this.error }, | ||
}); | ||
} | ||
} |