Challenge - 5 Problems
Error Page Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
What does this +error.svelte component display when an error occurs?
Consider this +error.svelte component in a SvelteKit app:
What will the user see if the server returns a 404 error with message "Not Found"?
<script>
export let error;
export let status;
</script>
<h1>Error {status}</h1>
<p>{error.message}</p>
What will the user see if the server returns a 404 error with message "Not Found"?
Attempts:
2 left
💡 Hint
The status prop shows the HTTP status code, and error.message shows the error text.
✗ Incorrect
The +error.svelte component receives the status and error props. It displays the status code (404) and the error message ('Not Found') exactly as passed.
📝 Syntax
intermediate1:30remaining
Which +error.svelte code snippet correctly exports the error and status props?
You want to access the error and status in your +error.svelte component. Which code snippet is correct?
Attempts:
2 left
💡 Hint
Props must be declared with 'export let' in Svelte components.
✗ Incorrect
In Svelte, to receive props, you declare them with 'export let'. Options A, B, and C are invalid syntax or do not export props correctly.
🔧 Debug
advanced2:30remaining
Why does this +error.svelte component fail to display the error message?
Given this +error.svelte code:
The error message does not show up. What is the cause?
<script>
export let error;
export let status;
</script>
<h1>Error {status}</h1>
<p>{error.msg}</p>The error message does not show up. What is the cause?
Attempts:
2 left
💡 Hint
Check the property name used to access the error text.
✗ Incorrect
The error object has a 'message' property, not 'msg'. Using 'error.msg' results in undefined, so nothing shows.
❓ state_output
advanced2:00remaining
What is the output when +error.svelte receives a 500 status with a custom error message?
This +error.svelte component:
Receives props: status = 500, error.message = "Server crashed".
What is the rendered output?
<script>
export let error;
export let status;
</script>
<h1>Oops! Error {status}</h1>
<p>{error.message}</p>Receives props: status = 500, error.message = "Server crashed".
What is the rendered output?
Attempts:
2 left
💡 Hint
The component uses the status and error.message props directly in the output.
✗ Incorrect
The component shows the status (500) and the exact error.message ('Server crashed') inside the tags.
🧠 Conceptual
expert3:00remaining
Which statement about +error.svelte in SvelteKit is TRUE?
Choose the correct statement about the +error.svelte file in a SvelteKit project.
Attempts:
2 left
💡 Hint
Think about how SvelteKit handles errors globally.
✗ Incorrect
+error.svelte is a special file that SvelteKit uses automatically to show error pages. It receives error info as props.