@jsenv/test 3.0.18 → 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,7 +845,7 @@ const createException = (reason, { rootDirectoryUrl } = {}) => {
845
845
  }
846
846
  reason.stackTrace = stackTrace;
847
847
  let stack = "";
848
- const name = reason.name || "Error";
848
+ const name = getErrorName(reason);
849
849
  const message = reason.message || "";
850
850
  stack += `${name}: ${message}`;
851
851
  if (stackTrace) {
@@ -876,12 +876,23 @@ const createException = (reason, { rootDirectoryUrl } = {}) => {
876
876
  if (isError) {
877
877
  // getOwnPropertyNames is not enough to copy .name and .message
878
878
  // on error instances
879
- exception.name = reason.name;
879
+ exception.name = getErrorName(reason);
880
880
  exception.message = reason.message;
881
881
  }
882
882
  return exception;
883
883
  };
884
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
+
885
896
  const getPropertiesFromEvalOrigin = (origin) => {
886
897
  // Most eval() calls are in this format
887
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.18",
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.6",
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,7 +159,7 @@ export const createException = (reason, { rootDirectoryUrl } = {}) => {
159
159
  }
160
160
  reason.stackTrace = stackTrace;
161
161
  let stack = "";
162
- const name = reason.name || "Error";
162
+ const name = getErrorName(reason);
163
163
  const message = reason.message || "";
164
164
  stack += `${name}: ${message}`;
165
165
  if (stackTrace) {
@@ -190,12 +190,23 @@ export const createException = (reason, { rootDirectoryUrl } = {}) => {
190
190
  if (isError) {
191
191
  // getOwnPropertyNames is not enough to copy .name and .message
192
192
  // on error instances
193
- exception.name = reason.name;
193
+ exception.name = getErrorName(reason);
194
194
  exception.message = reason.message;
195
195
  }
196
196
  return exception;
197
197
  };
198
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
+
199
210
  const getPropertiesFromEvalOrigin = (origin) => {
200
211
  // Most eval() calls are in this format
201
212
  const topLevelEvalMatch = /^eval at ([^(]+) \((.+):(\d+):(\d+)\)$/.exec(