@sveltejs/kit 2.0.1 → 2.0.2
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
|
@@ -2118,16 +2118,21 @@ async function load_data(url, invalid) {
|
|
|
2118
2118
|
|
|
2119
2119
|
const res = await native_fetch(data_url.href);
|
|
2120
2120
|
|
|
2121
|
-
// if `__data.json` doesn't exist or the server has an internal error,
|
|
2122
|
-
// fallback to native navigation so we avoid parsing the HTML error page as a JSON
|
|
2123
|
-
if (res.headers.get('content-type')?.includes('text/html')) {
|
|
2124
|
-
await native_navigation(url);
|
|
2125
|
-
}
|
|
2126
|
-
|
|
2127
2121
|
if (!res.ok) {
|
|
2128
2122
|
// error message is a JSON-stringified string which devalue can't handle at the top level
|
|
2129
2123
|
// turn it into a HttpError to not call handleError on the client again (was already handled on the server)
|
|
2130
|
-
|
|
2124
|
+
// if `__data.json` doesn't exist or the server has an internal error,
|
|
2125
|
+
// avoid parsing the HTML error page as a JSON
|
|
2126
|
+
/** @type {string | undefined} */
|
|
2127
|
+
let message;
|
|
2128
|
+
if (res.headers.get('content-type')?.includes('application/json')) {
|
|
2129
|
+
message = await res.json();
|
|
2130
|
+
} else if (res.status === 404) {
|
|
2131
|
+
message = 'Not Found';
|
|
2132
|
+
} else if (res.status === 500) {
|
|
2133
|
+
message = 'Internal Error';
|
|
2134
|
+
}
|
|
2135
|
+
throw new HttpError(res.status, message);
|
|
2131
2136
|
}
|
|
2132
2137
|
|
|
2133
2138
|
// TODO: fix eslint error / figure out if it actually applies to our situation
|
package/src/runtime/control.js
CHANGED
|
@@ -33,6 +33,7 @@ export class Redirect {
|
|
|
33
33
|
/**
|
|
34
34
|
* An error that was thrown from within the SvelteKit runtime that is not fatal and doesn't result in a 500, such as a 404.
|
|
35
35
|
* `SvelteKitError` goes through `handleError`.
|
|
36
|
+
* @extends Error
|
|
36
37
|
*/
|
|
37
38
|
export class SvelteKitError extends Error {
|
|
38
39
|
/**
|
package/src/version.js
CHANGED