h3 0.7.14 → 0.7.15

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
@@ -244,6 +244,18 @@ function createError(input) {
244
244
  return input;
245
245
  }
246
246
  const err = new H3Error(input.message ?? input.statusMessage, input.cause ? { cause: input.cause } : void 0);
247
+ if ("stack" in input) {
248
+ try {
249
+ Object.defineProperty(err, "stack", { get() {
250
+ return input.stack;
251
+ } });
252
+ } catch {
253
+ try {
254
+ err.stack = input.stack;
255
+ } catch {
256
+ }
257
+ }
258
+ }
247
259
  if (input.statusCode) {
248
260
  err.statusCode = input.statusCode;
249
261
  }
@@ -437,12 +449,12 @@ function createApp(options = {}) {
437
449
  if (!isError(_error)) {
438
450
  error.unhandled = true;
439
451
  }
440
- if (error.unhandled || error.fatal) {
441
- console.error("[h3]", error.fatal ? "[fatal]" : "[unhandled]", error);
442
- }
443
452
  if (options.onError) {
444
453
  await options.onError(error, event);
445
454
  } else {
455
+ if (error.unhandled || error.fatal) {
456
+ console.error("[h3]", error.fatal ? "[fatal]" : "[unhandled]", error);
457
+ }
446
458
  await sendError(event, error, !!options.debug);
447
459
  }
448
460
  }
package/dist/index.mjs CHANGED
@@ -236,6 +236,18 @@ function createError(input) {
236
236
  return input;
237
237
  }
238
238
  const err = new H3Error(input.message ?? input.statusMessage, input.cause ? { cause: input.cause } : void 0);
239
+ if ("stack" in input) {
240
+ try {
241
+ Object.defineProperty(err, "stack", { get() {
242
+ return input.stack;
243
+ } });
244
+ } catch {
245
+ try {
246
+ err.stack = input.stack;
247
+ } catch {
248
+ }
249
+ }
250
+ }
239
251
  if (input.statusCode) {
240
252
  err.statusCode = input.statusCode;
241
253
  }
@@ -429,12 +441,12 @@ function createApp(options = {}) {
429
441
  if (!isError(_error)) {
430
442
  error.unhandled = true;
431
443
  }
432
- if (error.unhandled || error.fatal) {
433
- console.error("[h3]", error.fatal ? "[fatal]" : "[unhandled]", error);
434
- }
435
444
  if (options.onError) {
436
445
  await options.onError(error, event);
437
446
  } else {
447
+ if (error.unhandled || error.fatal) {
448
+ console.error("[h3]", error.fatal ? "[fatal]" : "[unhandled]", error);
449
+ }
438
450
  await sendError(event, error, !!options.debug);
439
451
  }
440
452
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "h3",
3
- "version": "0.7.14",
3
+ "version": "0.7.15",
4
4
  "description": "Tiny JavaScript Server",
5
5
  "repository": "unjs/h3",
6
6
  "license": "MIT",