Error Handling in load
Throw error() or redirect() from load to handle failure cases cleanly.
Throwing Errors
Use error() from @sveltejs/kit to send a controlled HTTP error.
import { error } from "@sveltejs/kit";
if (!post) error(404, "Post not found");Status Code
The first argument is the HTTP status code (404, 401, 500, etc.).