Errors
Errors are an inevitable fact of software development. SvelteKit handles errors differently depending on where they occur, what kind of errors they are, and the nature of the incoming request.
Error objects
Every error passes through the handleError hook — which can log it and customise it — before it is rendered. The hook’s kind property identifies where the error came from: your app ('app'), SvelteKit ('framework'), validation of a remote function argument ('validation') or an unknown source ('unknown'). By default, all are represented as simple { status: number, message: string } objects.
You can add additional properties, like a code or a tracking id, as shown in the examples below. (When using TypeScript this requires you to redefine the Error type as described in Type safety below).
App errors
An app error is one thrown from your app code using the error function imported from @sveltejs/kit:
import { error