@jsenv/plugin-supervisor 1.4.7 → 1.4.9

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.
@@ -530,7 +530,7 @@ window.__supervisor__ = (() => {
530
530
  }
531
531
  // isError can be false when reason is an ErrorEvent for instance
532
532
  exception.isError = reason instanceof Error;
533
- exception.name = reason.constructor ? reason.constructor.name : reason.name || "Error";
533
+ exception.name = getErrorName(reason);
534
534
  exception.message = reason.message || message || "";
535
535
  let stackFrames;
536
536
  if (exception.isError && Error.captureStackTrace &&
@@ -599,7 +599,7 @@ window.__supervisor__ = (() => {
599
599
  }
600
600
  exception.stackTrace = stackTrace;
601
601
  let stack = "";
602
- const name = reason.constructor ? reason.constructor.name : reason.name || "Error";
602
+ const name = getErrorName(reason);
603
603
  const message = reason.message || "";
604
604
  stack += "".concat(name, ": ").concat(message);
605
605
  if (stackTrace) {
@@ -777,7 +777,7 @@ window.__supervisor__ = (() => {
777
777
  const getErrorStackTrace = error => {
778
778
  let stack = error.stack;
779
779
  if (!stack) return "";
780
- const name = error.constructor ? error.constructor.name : error.name;
780
+ const name = getErrorName(error);
781
781
  const messageInStack = "".concat(name, ": ").concat(error.message);
782
782
  if (stack.startsWith(messageInStack)) {
783
783
  stack = stack.slice(messageInStack.length);
@@ -932,7 +932,7 @@ window.__supervisor__ = (() => {
932
932
  });
933
933
  if (cause) {
934
934
  const causeText = stringifyStack({
935
- name: cause.constructor ? cause.constructor.name : cause.name,
935
+ name: getErrorName(cause),
936
936
  message: cause.reason ? generateClickableText(cause.reason) : cause.stack ? generateClickableText(cause.stack) : ""
937
937
  });
938
938
  if (causeText) {
@@ -1180,5 +1180,16 @@ window.__supervisor__ = (() => {
1180
1180
  });
1181
1181
  });
1182
1182
  };
1183
+ const getErrorName = value => {
1184
+ const {
1185
+ constructor
1186
+ } = value;
1187
+ if (constructor) {
1188
+ if (constructor.name !== "Object") {
1189
+ return constructor.name;
1190
+ }
1191
+ }
1192
+ return value.name || "Error";
1193
+ };
1183
1194
  return supervisor;
1184
1195
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/plugin-supervisor",
3
- "version": "1.4.7",
3
+ "version": "1.4.9",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -485,9 +485,7 @@ window.__supervisor__ = (() => {
485
485
  }
486
486
  // isError can be false when reason is an ErrorEvent for instance
487
487
  exception.isError = reason instanceof Error;
488
- exception.name = reason.constructor
489
- ? reason.constructor.name
490
- : reason.name || "Error";
488
+ exception.name = getErrorName(reason);
491
489
  exception.message = reason.message || message || "";
492
490
 
493
491
  let stackFrames;
@@ -559,9 +557,7 @@ window.__supervisor__ = (() => {
559
557
  exception.stackTrace = stackTrace;
560
558
 
561
559
  let stack = "";
562
- const name = reason.constructor
563
- ? reason.constructor.name
564
- : reason.name || "Error";
560
+ const name = getErrorName(reason);
565
561
  const message = reason.message || "";
566
562
  stack += `${name}: ${message}`;
567
563
  if (stackTrace) {
@@ -749,7 +745,7 @@ window.__supervisor__ = (() => {
749
745
  const getErrorStackTrace = (error) => {
750
746
  let stack = error.stack;
751
747
  if (!stack) return "";
752
- const name = error.constructor ? error.constructor.name : error.name;
748
+ const name = getErrorName(error);
753
749
  const messageInStack = `${name}: ${error.message}`;
754
750
  if (stack.startsWith(messageInStack)) {
755
751
  stack = stack.slice(messageInStack.length);
@@ -928,7 +924,7 @@ window.__supervisor__ = (() => {
928
924
  });
929
925
  if (cause) {
930
926
  const causeText = stringifyStack({
931
- name: cause.constructor ? cause.constructor.name : cause.name,
927
+ name: getErrorName(cause),
932
928
  message: cause.reason
933
929
  ? generateClickableText(cause.reason)
934
930
  : cause.stack
@@ -1265,5 +1261,15 @@ window.__supervisor__ = (() => {
1265
1261
  });
1266
1262
  };
1267
1263
 
1264
+ const getErrorName = (value) => {
1265
+ const { constructor } = value;
1266
+ if (constructor) {
1267
+ if (constructor.name !== "Object") {
1268
+ return constructor.name;
1269
+ }
1270
+ }
1271
+ return value.name || "Error";
1272
+ };
1273
+
1268
1274
  return supervisor;
1269
1275
  })();