h3 0.7.11 → 0.7.12

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/dist/index.cjs CHANGED
@@ -188,11 +188,12 @@ class H3Error extends Error {
188
188
  this.statusMessage = "Internal Server Error";
189
189
  }
190
190
  }
191
+ H3Error.__h3_error__ = true;
191
192
  function createError(input) {
192
193
  if (typeof input === "string") {
193
194
  return new H3Error(input);
194
195
  }
195
- if (input instanceof H3Error) {
196
+ if (isError(input)) {
196
197
  return input;
197
198
  }
198
199
  const err = new H3Error(input.message ?? input.statusMessage, input.cause ? { cause: input.cause } : void 0);
@@ -236,7 +237,7 @@ function sendError(event, error, debug) {
236
237
  event.res.end(JSON.stringify(responseBody, null, 2));
237
238
  }
238
239
  function isError(input) {
239
- return input instanceof H3Error;
240
+ return input?.constructor?.__h3_error__ === true;
240
241
  }
241
242
 
242
243
  const defineHandler = (handler) => handler;
package/dist/index.d.ts CHANGED
@@ -105,6 +105,7 @@ declare function createAppEventHandler(stack: Stack, options: AppOptions): Event
105
105
  * @property {Boolean} internal Setting this property to <code>true</code> will mark error as an internal error
106
106
  */
107
107
  declare class H3Error extends Error {
108
+ static __h3_error__: boolean;
108
109
  statusCode: number;
109
110
  fatal: boolean;
110
111
  unhandled: boolean;
package/dist/index.mjs CHANGED
@@ -180,11 +180,12 @@ class H3Error extends Error {
180
180
  this.statusMessage = "Internal Server Error";
181
181
  }
182
182
  }
183
+ H3Error.__h3_error__ = true;
183
184
  function createError(input) {
184
185
  if (typeof input === "string") {
185
186
  return new H3Error(input);
186
187
  }
187
- if (input instanceof H3Error) {
188
+ if (isError(input)) {
188
189
  return input;
189
190
  }
190
191
  const err = new H3Error(input.message ?? input.statusMessage, input.cause ? { cause: input.cause } : void 0);
@@ -228,7 +229,7 @@ function sendError(event, error, debug) {
228
229
  event.res.end(JSON.stringify(responseBody, null, 2));
229
230
  }
230
231
  function isError(input) {
231
- return input instanceof H3Error;
232
+ return input?.constructor?.__h3_error__ === true;
232
233
  }
233
234
 
234
235
  const defineHandler = (handler) => handler;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "h3",
3
- "version": "0.7.11",
3
+ "version": "0.7.12",
4
4
  "description": "Tiny JavaScript Server",
5
5
  "repository": "unjs/h3",
6
6
  "license": "MIT",