{"record":{"id":"4306b55559b2e70a","repo":"sveltejs/kit","slug":"the-status-property-of-handleerror-is-deprecat","errorCode":null,"errorMessage":"The `status` property of `handleError` is deprecated. Use `error.status` for expected and framework errors, or `500` for unexpected errors.","messagePattern":"The `status` property of `handleError` is deprecated\\. Use `error\\.status` for expected and framework errors, or `500` for unexpected errors\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/kit/src/utils/error.js","lineNumber":57,"sourceCode":" * @param {unknown} error\n */\nexport function get_status(error) {\n\treturn error instanceof HttpError || error instanceof SvelteKitError ? error.status : 500;\n}\n\n/**\n * Adds development-only compatibility accessors for the former top-level `status` and `message`\n * properties of the `handleError` hook input.\n * @template {object} T\n * @param {T} input\n * @param {{ status: number; message: string }} fallback\n * @returns {T}\n */\nexport function add_deprecated_handle_error_properties(input, fallback) {\n\tObject.defineProperties(input, {\n\t\tstatus: {\n\t\t\tget() {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t'The `status` property of `handleError` is deprecated. Use `error.status` for expected and framework errors, or `500` for unexpected errors.'\n\t\t\t\t);\n\t\t\t\treturn fallback.status;\n\t\t\t}\n\t\t},\n\t\tmessage: {\n\t\t\tget() {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"The `message` property of `handleError` is deprecated. Use `error.message` for expected and framework errors, or 'Internal Error' for unexpected errors.\"\n\t\t\t\t);\n\t\t\t\treturn fallback.message;\n\t\t\t}\n\t\t}\n\t});\n\n\treturn input;\n}\n","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/utils/error.js#L39-L75","documentation":"The object passed to the `handleError` hook carries a legacy `status` property implemented as a getter that warns on access. It is deprecated because status semantics differ between expected/framework errors and unexpected errors; developers should use `error.status` or hardcode 500.","triggerScenarios":"Reading `status` on the first argument inside a `handleError` hook in hooks.server.js (the getter installed by `add_deprecated_handle_error_properties` is evaluated).","commonSituations":"Old hook implementations migrated from earlier SvelteKit versions; error-reporting integrations that serialize the whole error object including `status`; copying hook examples from outdated tutorials.","solutions":["Replace `error.status` in the hook with logic: use `error.status` for HttpError/SvelteKitError, else 500","Destructure only `message` or use the second (fallback/envelope) argument's fields deliberately, accepting the deprecation temporarily","Update error-reporting code to log `error.status ?? 500` from the actual error"],"exampleFix":"// before\nexport const handleError = ({ error, status }) => ({ message: error.message, status });\n// after\nexport const handleError = ({ error }) => ({\n  message: error.message,\n  status: error instanceof HttpError || error instanceof SvelteKitError ? error.status : 500\n});","handlingStrategy":"type-guard","validationCode":"// compute status yourself instead of reading deprecated prop\nfunction resolveStatus(error) {\n  return error && typeof error === 'object' && 'status' in error && typeof error.status === 'number'\n    ? error.status\n    : 500;\n}","typeGuard":"function hasOwnStatus(error) {\n  return error instanceof Error && 'status' in error && typeof error.status === 'number';\n}","tryCatchPattern":null,"preventionTips":["Never read `status` directly off the handleError argument","Use instanceof checks for HttpError/SvelteKitError to get real status","Update error reporting SDKs to avoid serializing deprecated getters"],"tags":["deprecation","handleerror","hooks"],"backgroundTag":"deprecated-handle-error-status","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}