shelving 1.150.1 → 1.150.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 +1 -1
- package/util/http.js +5 -2
package/package.json
CHANGED
package/util/http.js
CHANGED
|
@@ -117,8 +117,11 @@ export function getErrorResponse(reason, debug = false) {
|
|
|
117
117
|
// Throw `RequestError` to set a custom status code (e.g. `UnauthorizedError`).
|
|
118
118
|
const status = reason instanceof RequestError ? reason.code : 500;
|
|
119
119
|
// Throw `Error` to return `{ message: "etc" }` to the client (but only if `debug` is true so we don't leak error details to the client).
|
|
120
|
-
if (debug && isError(reason))
|
|
121
|
-
|
|
120
|
+
if (debug && isError(reason)) {
|
|
121
|
+
// Manually destructure because `Error.prototype.message` is not enumerable.
|
|
122
|
+
const { message, ...rest } = reason;
|
|
123
|
+
return Response.json({ message, ...rest }, { status });
|
|
124
|
+
}
|
|
122
125
|
// Otherwise return a generic error message with no details.
|
|
123
126
|
return new Response(undefined, { status });
|
|
124
127
|
}
|