Skip to content

Commit 8235e0b

Browse files
author
Rich Harris
committed
simplify some stuff
1 parent 6564804 commit 8235e0b

File tree

6 files changed

+15
-46
lines changed

6 files changed

+15
-46
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const emojis = {
2+
// TODO add the rest!
3+
420: '🫠',
4+
500: '💥'
5+
};

content/tutorial/03-sveltekit/06-errors-and-redirects/02-error-pages/README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@ The default error page is somewhat bland. We can customize it by creating a `src
1010
/// file: src/routes/+error.svelte
1111
<script>
1212
import { page } from '$app/stores';
13-
14-
const emojis = {
15-
// TODO add the rest!
16-
420: '🫠',
17-
500: '💥'
18-
};
13+
import { emojis } from './emojis.js';
1914
</script>
2015
2116
<h1>{$page.status} {$page.error.message}</h1>

content/tutorial/03-sveltekit/06-errors-and-redirects/02-error-pages/app-b/src/routes/+error.svelte

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
<script>
22
import { page } from '$app/stores';
3-
4-
const emojis = {
5-
// TODO add the rest!
6-
420: '🫠',
7-
500: '💥'
8-
};
3+
import { emojis } from './emojis.js';
94
</script>
105

116
<h1>{$page.status} {$page.error.message}</h1>

content/tutorial/03-sveltekit/06-errors-and-redirects/03-fallback-errors/README.md

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,17 @@ Add a new `src/routes/+layout.server.js` file to see this in action:
99
```js
1010
/// file: src/routes/+layout.server.js
1111
export function load() {
12-
throw new Error('😬');
12+
throw new Error('yikes');
1313
}
1414
```
1515

1616
You can customise the fallback error page. Create a `src/error.html` file:
1717

1818
```html
1919
/// file: src/error.html
20-
<!DOCTYPE html>
21-
<html lang="en">
22-
<head>
23-
<meta charset="utf-8" />
24-
<title>%sveltekit.error.message%</title>
25-
<style>
26-
body {
27-
color: #ff531a;
28-
}
29-
</style>
30-
</head>
31-
<body>
32-
<h1>Game over</h1>
33-
<p>Error code %sveltekit.status%</p>
34-
</body>
35-
</html>
20+
<h1>Game over</h1>
21+
<p>Code %sveltekit.status%</p>
22+
<p>%sveltekit.error.message%</p>
3623
```
3724

3825
This file can include the following:
Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
<!DOCTYPE html>
2-
<html lang="en">
3-
<head>
4-
<meta charset="utf-8" />
5-
<title>%sveltekit.error.message%</title>
6-
<style>
7-
body {
8-
color: #ff531a;
9-
}
10-
</style>
11-
</head>
12-
<body>
13-
<h1>Game over</h1>
14-
<p>Error code %sveltekit.status%</p>
15-
</body>
16-
</html>
1+
<h1>Game over</h1>
2+
<p>Code %sveltekit.status%</p>
3+
<p>%sveltekit.error.message%</p>
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export function load() {
2-
throw new Error('😬');
2+
throw new Error('yikes');
33
}

0 commit comments

Comments
 (0)