@jsenv/test 3.0.19 → 3.0.20

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.
@@ -845,9 +845,7 @@ const createException = (reason, { rootDirectoryUrl } = {}) => {
845
845
  }
846
846
  reason.stackTrace = stackTrace;
847
847
  let stack = "";
848
- const name = reason.constructor
849
- ? reason.constructor.name
850
- : reason.name || "Error";
848
+ const name = getErrorName(reason);
851
849
  const message = reason.message || "";
852
850
  stack += `${name}: ${message}`;
853
851
  if (stackTrace) {
@@ -878,12 +876,23 @@ const createException = (reason, { rootDirectoryUrl } = {}) => {
878
876
  if (isError) {
879
877
  // getOwnPropertyNames is not enough to copy .name and .message
880
878
  // on error instances
881
- exception.name = reason.constructor ? reason.constructor.name : reason.name;
879
+ exception.name = getErrorName(reason);
882
880
  exception.message = reason.message;
883
881
  }
884
882
  return exception;
885
883
  };
886
884
 
885
+ const getErrorName = (value) => {
886
+ const { constructor } = value;
887
+ if (constructor === "Object") {
888
+ return value.name || "Error";
889
+ }
890
+ if (constructor) {
891
+ return constructor.name;
892
+ }
893
+ return value.name || "Error";
894
+ };
895
+
887
896
  const getPropertiesFromEvalOrigin = (origin) => {
888
897
  // Most eval() calls are in this format
889
898
  const topLevelEvalMatch = /^eval at ([^(]+) \((.+):(\d+):(\d+)\)$/.exec(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/test",
3
- "version": "3.0.19",
3
+ "version": "3.0.20",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -42,7 +42,7 @@
42
42
  "@jsenv/filesystem": "4.6.8",
43
43
  "@jsenv/github-check-run": "0.1.13",
44
44
  "@jsenv/humanize": "1.1.2",
45
- "@jsenv/plugin-supervisor": "1.4.7",
45
+ "@jsenv/plugin-supervisor": "1.4.8",
46
46
  "@jsenv/url-meta": "8.4.0",
47
47
  "@jsenv/urls": "2.2.6",
48
48
  "@jsenv/utils": "2.1.1",
@@ -159,9 +159,7 @@ export const createException = (reason, { rootDirectoryUrl } = {}) => {
159
159
  }
160
160
  reason.stackTrace = stackTrace;
161
161
  let stack = "";
162
- const name = reason.constructor
163
- ? reason.constructor.name
164
- : reason.name || "Error";
162
+ const name = getErrorName(reason);
165
163
  const message = reason.message || "";
166
164
  stack += `${name}: ${message}`;
167
165
  if (stackTrace) {
@@ -192,12 +190,23 @@ export const createException = (reason, { rootDirectoryUrl } = {}) => {
192
190
  if (isError) {
193
191
  // getOwnPropertyNames is not enough to copy .name and .message
194
192
  // on error instances
195
- exception.name = reason.constructor ? reason.constructor.name : reason.name;
193
+ exception.name = getErrorName(reason);
196
194
  exception.message = reason.message;
197
195
  }
198
196
  return exception;
199
197
  };
200
198
 
199
+ const getErrorName = (value) => {
200
+ const { constructor } = value;
201
+ if (constructor === "Object") {
202
+ return value.name || "Error";
203
+ }
204
+ if (constructor) {
205
+ return constructor.name;
206
+ }
207
+ return value.name || "Error";
208
+ };
209
+
201
210
  const getPropertiesFromEvalOrigin = (origin) => {
202
211
  // Most eval() calls are in this format
203
212
  const topLevelEvalMatch = /^eval at ([^(]+) \((.+):(\d+):(\d+)\)$/.exec(