Closed IvankoB closed 2 years ago
routes/
│ +error.svelte
│ +layout.svelte
│ +page.svelte
│
└───home
│ +error.svelte
│ +layout.svelte
│ +page.svelte
│
└───[...404]
+page.server.js
with '[...404]/+page.server.js' :
import { error } from '@sveltejs/kit';
/** @type {import('../../../.svelte-kit/types/src/routes/home/$types').PageServerLoad} */
export async function load({ params}) {
throw error(404,'No such page');
}
works (shows '/home/+error.svelte' in '/home/+layout.svelte' in '+layout.svelte') but looks hacky.
Using https://kit.svelte.dev/docs/load#errors in a +page.js
load
is the intended way to do this.
Describe the bug
Trying to workaround it with "(..)" grouping and naming file as "+error@.svelte" is rejected.
The directory structure after aplying advices from https://github.com/sveltejs/kit/discussions/6531
While navgating to non-existent 'routes/home/badgy', the desired 'routes/home/[...catchall]/+error.svelte' is ignored and 'routes/+error.svelte' is displayed instead inserted in the root 'routes/+layout.svelte'. Though 'routes/home/[...catchall]/+page.svelte' is inserted in 'routes/home/+layout.svelte' as expected. This way this page can be used instead of error page but it looks like an workaround (has httpStatus =200 instead of expected 404 etc )
Reproduction
Any project with non-root route and layout.
Logs
System Info
Severity
serious, but I can work around it
Additional Information
No response