@sveltejs/kit 1.0.0-next.488 → 1.0.0-next.489
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -68,7 +68,7 @@ export class Server {
|
|
|
68
68
|
get request() {
|
|
69
69
|
throw new Error('request in handleError has been replaced with event. See https://github.com/sveltejs/kit/pull/3384 for details');
|
|
70
70
|
}
|
|
71
|
-
}) ?? { message: 'Internal Error' };
|
|
71
|
+
}) ?? { message: event.routeId ? 'Internal Error' : 'Not Found' };
|
|
72
72
|
},
|
|
73
73
|
hooks: null,
|
|
74
74
|
manifest,
|
|
@@ -350,7 +350,7 @@ export async function dev(vite, vite_config, svelte_config) {
|
|
|
350
350
|
user_hooks.handleError ||
|
|
351
351
|
(({ error: e }) => {
|
|
352
352
|
const error = /** @type {Error & { frame?: string }} */ (e);
|
|
353
|
-
console.error(colors.bold().red(error.message));
|
|
353
|
+
console.error(colors.bold().red(error.message ?? error)); // Could be anything
|
|
354
354
|
if (error.frame) {
|
|
355
355
|
console.error(colors.gray(error.frame));
|
|
356
356
|
}
|
|
@@ -432,7 +432,7 @@ export async function dev(vite, vite_config, svelte_config) {
|
|
|
432
432
|
'request in handleError has been replaced with event. See https://github.com/sveltejs/kit/pull/3384 for details'
|
|
433
433
|
);
|
|
434
434
|
}
|
|
435
|
-
}) ?? { message: 'Internal Error' }
|
|
435
|
+
}) ?? { message: event.routeId ? 'Internal Error' : 'Not Found' }
|
|
436
436
|
);
|
|
437
437
|
},
|
|
438
438
|
hooks,
|
|
@@ -1513,7 +1513,10 @@ async function load_data(url, invalid) {
|
|
|
1513
1513
|
* @returns {App.PageError}
|
|
1514
1514
|
*/
|
|
1515
1515
|
function handle_error(error, event) {
|
|
1516
|
-
return
|
|
1516
|
+
return (
|
|
1517
|
+
hooks.handleError({ error, event }) ??
|
|
1518
|
+
/** @type {any} */ ({ message: event.routeId ? 'Internal Error' : 'Not Found' })
|
|
1519
|
+
);
|
|
1517
1520
|
}
|
|
1518
1521
|
|
|
1519
1522
|
// TODO remove for 1.0
|
|
@@ -4,9 +4,11 @@ import {
|
|
|
4
4
|
handle_error_and_jsonify,
|
|
5
5
|
GENERIC_ERROR,
|
|
6
6
|
get_option,
|
|
7
|
-
static_error_page
|
|
7
|
+
static_error_page,
|
|
8
|
+
redirect_response
|
|
8
9
|
} from '../utils.js';
|
|
9
10
|
import { create_fetch } from './fetch.js';
|
|
11
|
+
import { HttpError, Redirect } from '../../control.js';
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* @typedef {import('./types.js').Loaded} Loaded
|
|
@@ -87,6 +89,16 @@ export async function respond_with_error({ event, options, state, status, error,
|
|
|
87
89
|
resolve_opts
|
|
88
90
|
});
|
|
89
91
|
} catch (error) {
|
|
90
|
-
|
|
92
|
+
// Edge case: If route is a 404 and the user redirects to somewhere from the root layout,
|
|
93
|
+
// we end up here.
|
|
94
|
+
if (error instanceof Redirect) {
|
|
95
|
+
return redirect_response(error.status, error.location, cookies);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return static_error_page(
|
|
99
|
+
options,
|
|
100
|
+
error instanceof HttpError ? error.status : 500,
|
|
101
|
+
handle_error_and_jsonify(event, options, error).message
|
|
102
|
+
);
|
|
91
103
|
}
|
|
92
104
|
}
|