sveltejs/kit · warning
The `message` property of `handleError` is deprecated. Use `
Error message
The `message` property of `handleError` is deprecated. Use `error.message` for expected and framework errors, or 'Internal Error' for unexpected errors.
What it means
Like the `status` twin, `message` on the `handleError` error argument is a deprecated getter that warns when read. For unexpected errors the real message is hidden for security, so the getter returns the fallback ('Internal Error'), and developers are told to use `error.message` for expected/framework errors or the literal string otherwise.
Source
Thrown at packages/kit/src/utils/error.js:65
* properties of the `handleError` hook input.
* @template {object} T
* @param {T} input
* @param {{ status: number; message: string }} fallback
* @returns {T}
*/
export function add_deprecated_handle_error_properties(input, fallback) {
Object.defineProperties(input, {
status: {
get() {
console.warn(
'The `status` property of `handleError` is deprecated. Use `error.status` for expected and framework errors, or `500` for unexpected errors.'
);
return fallback.status;
}
},
message: {
get() {
console.warn(
"The `message` property of `handleError` is deprecated. Use `error.message` for expected and framework errors, or 'Internal Error' for unexpected errors."
);
return fallback.message;
}
}
});
return input;
}
View on GitHub (pinned to 03f1687fe6)
Solutions
- Read `error.message` from the original error and provide your own 'Internal Error' fallback for unexpected errors
- Update the hook return to compute message explicitly based on error type
- Silence noise by removing all reads of the deprecated properties
Example fix
// before
return { message: error.message };
// after
return { message: error instanceof Error && 'status' in error ? error.message : 'Internal Error' }; Defensive patterns
Strategy: type-guard
Validate before calling
function resolveMessage(error) {
return error instanceof Error && 'status' in error && error.status != null
? error.message
: 'Internal Error';
} Type guard
function isFrameworkError(error) {
return error instanceof Error && typeof error.message === 'string' && 'status' in error;
} Prevention
- Build message explicitly with a fallback literal 'Internal Error'
- Avoid blanket serialization of the hook's error argument
- Migrate old hook templates from docs/tutorials
When it happens
Trigger: Accessing `.message` on the error argument inside `handleError` in hooks.server.js, triggering the getter defined by `add_deprecated_handle_error_properties`.
Common situations: Legacy hook code returning `{ message: error.message }`; third-party error trackers serializing the hook argument; templates copied from pre-deprecation docs.
Related errors
- The `status` property of `handleError` is deprecated. Use `e
- To use an async `handleError` hook to handle errors that occ
- Failed to get response header "set-cookie" — it must be incl
- Use `event.cookies.set(name, value, options)` instead of `ev
- Reading `config.kit` inside adapters is deprecated — it shou
AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02).
Data as JSON: /api/errors/9ac99cb22d0eb33f.
Report an issue: GitHub.