@util.js/errors 0.41.0 → 0.41.2

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.
@@ -1,42 +1,26 @@
1
1
  "use strict";
2
+
2
3
  /*
3
4
  * See {@link Errors#AsyncError}.
4
5
  */
5
-
6
6
  var _Reflect$construct = require("@babel/runtime-corejs3/core-js-stable/reflect/construct");
7
-
8
7
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
9
-
10
8
  var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
11
-
12
9
  var _splice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/splice"));
13
-
14
10
  var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
15
-
16
11
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
17
-
18
12
  var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/inherits"));
19
-
20
13
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
21
-
22
14
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/getPrototypeOf"));
23
-
24
15
  var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/wrapNativeSuper"));
25
-
26
16
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
27
-
28
17
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
29
-
30
18
  module.exports = /*#__PURE__*/function (_Error) {
31
19
  (0, _inherits2["default"])(AsyncError, _Error);
32
-
33
20
  var _super = _createSuper(AsyncError);
34
-
35
21
  function AsyncError(callerError, asyncError, message) {
36
22
  var _context, _context2, _context3, _context4, _context5;
37
-
38
23
  var _this;
39
-
40
24
  (0, _classCallCheck2["default"])(this, AsyncError);
41
25
  _this = _super.call(this, message != null ? message : getErrorProperty(asyncError, "message"));
42
26
  if (!callerError) throw new TypeError((0, _concat["default"])(_context = "".concat(_this.constructor.name, "'s constructor expects a defined callerError, but it was ")).call(_context, callerError, "."));
@@ -44,20 +28,17 @@ module.exports = /*#__PURE__*/function (_Error) {
44
28
  _this.name = _this.constructor.name;
45
29
  _this.original = asyncError;
46
30
  _this.newStack = _this.stack;
47
- var callerStack = " at " + (0, _splice["default"])(_context3 = callerError.stack.split(" at ")).call(_context3, 2).join(" at "); // If asyncError.stack is falsy, then let us just try asyncError;
31
+ var callerStack = " at " + (0, _splice["default"])(_context3 = callerError.stack.split(" at ")).call(_context3, 2).join(" at ");
32
+ // If asyncError.stack is falsy, then let us just try asyncError;
48
33
  // asyncError may be a string.
49
-
50
34
  var asyncErrorStack = getErrorProperty(asyncError, "stack");
51
35
  _this.stack = (0, _concat["default"])(_context4 = (0, _concat["default"])(_context5 = "".concat(_this.stack, "\n")).call(_context5, callerStack, "\n")).call(_context4, asyncErrorStack);
52
36
  return _this;
53
37
  }
54
-
55
38
  return AsyncError;
56
39
  }( /*#__PURE__*/(0, _wrapNativeSuper2["default"])(Error));
57
-
58
40
  function getErrorProperty(error, property) {
59
41
  if (error[property]) return error[property];
60
-
61
42
  try {
62
43
  return (0, _stringify["default"])(error);
63
44
  } catch (e) {
package/dist/Errors.js CHANGED
@@ -1,22 +1,18 @@
1
1
  "use strict";
2
+
2
3
  /**
3
4
  * JavaScript utility methods for [errors]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error}
4
5
  *
5
6
  * @public
6
7
  * @class Errors
7
8
  */
8
-
9
9
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
10
-
11
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
12
-
13
11
  var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
14
-
15
12
  module.exports = /*#__PURE__*/function () {
16
13
  function Errors() {
17
14
  (0, _classCallCheck2["default"])(this, Errors);
18
15
  }
19
-
20
16
  (0, _createClass2["default"])(Errors, [{
21
17
  key: "catch",
22
18
  value:
@@ -88,12 +84,12 @@ module.exports = /*#__PURE__*/function () {
88
84
  */
89
85
  function _catch(promise, message) {
90
86
  var _this = this;
91
-
92
87
  var callerError = new Error();
93
88
  return promise["catch"](function (error) {
94
89
  throw new _this.AsyncError(callerError, error, message);
95
90
  });
96
91
  }
92
+
97
93
  /**
98
94
  * An error that preserves the stack trace of the thread that calls an asynchronous function.
99
95
  *
@@ -102,7 +98,6 @@ module.exports = /*#__PURE__*/function () {
102
98
  * @public
103
99
  * @class Errors#AsyncError
104
100
  */
105
-
106
101
  }, {
107
102
  key: "AsyncError",
108
103
  get: function get() {
@@ -118,6 +113,7 @@ module.exports = /*#__PURE__*/function () {
118
113
  get: function get() {
119
114
  return require("./MissingError");
120
115
  }
116
+
121
117
  /**
122
118
  * A wrapper of another error used for rethrowing.
123
119
  *
@@ -160,7 +156,6 @@ module.exports = /*#__PURE__*/function () {
160
156
  * @public
161
157
  * @class Errors#RethrownError
162
158
  */
163
-
164
159
  }, {
165
160
  key: "RethrownError",
166
161
  get: function get() {
@@ -1,40 +1,26 @@
1
1
  "use strict";
2
2
 
3
3
  var _Reflect$construct = require("@babel/runtime-corejs3/core-js-stable/reflect/construct");
4
-
5
4
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
6
-
7
5
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
8
-
9
6
  var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
10
-
11
7
  var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/inherits"));
12
-
13
8
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
14
-
15
9
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/getPrototypeOf"));
16
-
17
10
  var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/wrapNativeSuper"));
18
-
19
11
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
20
-
21
12
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
22
-
23
13
  module.exports = /*#__PURE__*/function (_TypeError) {
24
14
  (0, _inherits2["default"])(FalsyError, _TypeError);
25
-
26
15
  var _super = _createSuper(FalsyError);
27
-
28
16
  function FalsyError(argumentValue, argumentName, functionName) {
29
17
  var _this;
30
-
31
18
  (0, _classCallCheck2["default"])(this, FalsyError);
32
19
  _this = _super.call(this, argumentValue ? "Why are you creating a FalsyError with a truthy `argumentValue`: '" + argumentValue + "'?" : (functionName || "We") + " expected " + (argumentName ? "`" + argumentName + "`" : "an argument") + " to be truthy. " + (argumentName ? "`" + argumentName + "`" : "It") + " is the falsy value " + (argumentValue === "" ? "''" : argumentValue) + ".");
33
20
  _this.name = _this.constructor.name;
34
21
  _this.argumentName = argumentName;
35
22
  return _this;
36
23
  }
37
-
38
24
  (0, _createClass2["default"])(FalsyError, null, [{
39
25
  key: "check",
40
26
  value: function check(argumentValue, argumentName, functionName) {
@@ -1,40 +1,26 @@
1
1
  "use strict";
2
2
 
3
3
  var _Reflect$construct = require("@babel/runtime-corejs3/core-js-stable/reflect/construct");
4
-
5
4
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
6
-
7
5
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
8
-
9
6
  var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
10
-
11
7
  var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/inherits"));
12
-
13
8
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
14
-
15
9
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/getPrototypeOf"));
16
-
17
10
  var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/wrapNativeSuper"));
18
-
19
11
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
20
-
21
12
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
22
-
23
13
  module.exports = /*#__PURE__*/function (_TypeError) {
24
14
  (0, _inherits2["default"])(MissingError, _TypeError);
25
-
26
15
  var _super = _createSuper(MissingError);
27
-
28
16
  function MissingError(argumentValue, argumentName, functionName) {
29
17
  var _this;
30
-
31
18
  (0, _classCallCheck2["default"])(this, MissingError);
32
19
  _this = _super.call(this, argumentValue != null ? "Why are you creating a MissingError with a defined `argumentValue`: '" + argumentValue + "'?" : (functionName || "We") + " expected " + (argumentName ? "`" + argumentName + "`" : "an argument") + " to be defined. " + (argumentName ? "`" + argumentName + "`" : "It") + " is '" + argumentValue + "'.");
33
20
  _this.name = _this.constructor.name;
34
21
  _this.argumentName = argumentName;
35
22
  return _this;
36
23
  }
37
-
38
24
  (0, _createClass2["default"])(MissingError, null, [{
39
25
  key: "check",
40
26
  value: function check(argumentValue, argumentName, functionName) {
@@ -1,40 +1,25 @@
1
1
  "use strict";
2
+
2
3
  /*
3
4
  * See {@link Errors#RethrownError}.
4
5
  */
5
-
6
6
  var _Reflect$construct = require("@babel/runtime-corejs3/core-js-stable/reflect/construct");
7
-
8
7
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
9
-
10
8
  var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
11
-
12
9
  var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
13
-
14
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
15
-
16
11
  var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/inherits"));
17
-
18
12
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
19
-
20
13
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/getPrototypeOf"));
21
-
22
14
  var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/wrapNativeSuper"));
23
-
24
15
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
25
-
26
16
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
27
-
28
17
  module.exports = /*#__PURE__*/function (_Error) {
29
18
  (0, _inherits2["default"])(RethrownError, _Error);
30
-
31
19
  var _super = _createSuper(RethrownError);
32
-
33
20
  function RethrownError(error, message) {
34
21
  var _context;
35
-
36
22
  var _this;
37
-
38
23
  (0, _classCallCheck2["default"])(this, RethrownError);
39
24
  _this = _super.call(this, message != null ? message : getErrorProperty(error, "message"));
40
25
  if (!error) throw new TypeError("RethrownError's constructor expects a defined error, but it was ".concat(error, "."));
@@ -45,13 +30,10 @@ module.exports = /*#__PURE__*/function (_Error) {
45
30
  _this.stack = (0, _concat["default"])(_context = "".concat(_this.stack, "\n")).call(_context, errorStack);
46
31
  return _this;
47
32
  }
48
-
49
33
  return RethrownError;
50
34
  }( /*#__PURE__*/(0, _wrapNativeSuper2["default"])(Error));
51
-
52
35
  function getErrorProperty(error, property) {
53
36
  if (error[property]) return error[property];
54
-
55
37
  try {
56
38
  return (0, _stringify["default"])(error);
57
39
  } catch (e) {
package/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
 
3
+ // eslint-disable-next-line no-var
3
4
  var Errors = require("./dist/Errors");
4
5
  module.exports = new Errors();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Chris Topher <c@creemama.com>",
3
3
  "dependencies": {
4
- "@babel/runtime-corejs3": "7.14.0"
4
+ "@babel/runtime-corejs3": "7.20.1"
5
5
  },
6
6
  "description": "JavaScript utility methods for errors",
7
7
  "keywords": [
@@ -25,6 +25,6 @@
25
25
  "type": "git",
26
26
  "url": "https://github.com/creemama/utiljs/tree/master/packages/utiljs-errors"
27
27
  },
28
- "version": "0.41.0",
29
- "gitHead": "1ae0fda34e06ffbc546c5ba0025b0b59a0c7727d"
28
+ "version": "0.41.2",
29
+ "gitHead": "174b81ec0ead0221b9bb6617bc254b025bd20a5a"
30
30
  }
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
 
3
- const { AssertionError, expect } = require("chai"),
4
- errors = require(".."),
5
- { AsyncError, RethrownError } = errors;
3
+ const { expect } = require("chai");
4
+ const errors = require("..");
5
+ const { AsyncError, RethrownError } = errors;
6
6
 
7
7
  describe("Errors#catch(promise)", () => {
8
8
  it("should return a Promise that throws an AsyncError upon rejection", () => {
@@ -33,6 +33,7 @@ describe("Errors#catch(promise)", () => {
33
33
  });
34
34
  it("should return a Promise that throws an AsyncError upon rejecting with a string", () => {
35
35
  function rejectAPromise() {
36
+ // eslint-disable-next-line prefer-promise-reject-errors
36
37
  return Promise.reject("ENTITY_NOT_FOUND");
37
38
  }
38
39
  return errors.catch(rejectAPromise()).catch((error) => {
@@ -45,6 +46,7 @@ describe("Errors#catch(promise)", () => {
45
46
  });
46
47
  it("should return a Promise that throws an AsyncError upon rejecting with an array", () => {
47
48
  function rejectAPromise() {
49
+ // eslint-disable-next-line prefer-promise-reject-errors
48
50
  return Promise.reject([{ code: "1234" }]);
49
51
  }
50
52
  return errors.catch(rejectAPromise()).catch((error) => {
@@ -104,6 +106,7 @@ describe("new Errors#RethrownError(message, error)", () => {
104
106
  });
105
107
  it("should create a rethrown error from a thrown string", () => {
106
108
  function throwAString() {
109
+ // eslint-disable-next-line no-throw-literal
107
110
  throw "ENTITY_NOT_FOUND";
108
111
  }
109
112
  function rethrowTheString() {
@@ -141,6 +144,7 @@ describe("new Errors#RethrownError(message, error)", () => {
141
144
  });
142
145
  it("should create a rethrown error from a thrown array", () => {
143
146
  function throwAnArray() {
147
+ // eslint-disable-next-line no-throw-literal
144
148
  throw [{ code: "1234" }];
145
149
  }
146
150
  function rethrowTheArray() {
@@ -7,7 +7,7 @@ describe("FalsyError#check", () => {
7
7
  it('should throw a FalsyError given a falsy argument value: (NaN, "argument", "Lawyer#argue").', () => {
8
8
  try {
9
9
  FalsyError.check(NaN, "argument", "Lawyer#argue");
10
- throw "The method did not throw an error.";
10
+ throw new Error("The method did not throw an error.");
11
11
  } catch (e) {
12
12
  expect(e).to.be.an.instanceof(FalsyError);
13
13
  expect(e.message).to.equal(
@@ -20,7 +20,7 @@ describe("FalsyError#check", () => {
20
20
  it('should throw a FalsyError given a falsy argument value: (false, "argument").', () => {
21
21
  try {
22
22
  FalsyError.check(false, "argument");
23
- throw "The method did not throw an error.";
23
+ throw new Error("The method did not throw an error.");
24
24
  } catch (e) {
25
25
  expect(e).to.be.an.instanceof(FalsyError);
26
26
  expect(e.message).to.equal(
@@ -33,7 +33,7 @@ describe("FalsyError#check", () => {
33
33
  it('should throw a FalsyError given a falsy argument value: (undefined, null, "Lawyer#argue").', () => {
34
34
  try {
35
35
  FalsyError.check(undefined, null, "Lawyer#argue");
36
- throw "The method did not throw an error.";
36
+ throw new Error("The method did not throw an error.");
37
37
  } catch (e) {
38
38
  expect(e).to.be.an.instanceof(FalsyError);
39
39
  expect(e.message).to.equal(
@@ -46,7 +46,7 @@ describe("FalsyError#check", () => {
46
46
  it("should throw a FalsyError given a falsy argument value: (null).", () => {
47
47
  try {
48
48
  FalsyError.check(null);
49
- throw "The method did not throw an error.";
49
+ throw new Error("The method did not throw an error.");
50
50
  } catch (e) {
51
51
  expect(e).to.be.an.instanceof(FalsyError);
52
52
  expect(e.message).to.equal(
@@ -7,7 +7,7 @@ describe("MissingError#check", () => {
7
7
  it('should throw a MissingError given a \'null\' argument value: (null, "argument", "Lawyer#argue").', () => {
8
8
  try {
9
9
  MissingError.check(null, "argument", "Lawyer#argue");
10
- throw "The method did not throw an error.";
10
+ throw new Error("The method did not throw an error.");
11
11
  } catch (e) {
12
12
  expect(e).to.be.an.instanceof(MissingError);
13
13
  expect(e.argumentName).to.equal("argument");
@@ -17,7 +17,7 @@ describe("MissingError#check", () => {
17
17
  it("should throw a MissingError given a 'null' argument value: (null, \"argument\").", () => {
18
18
  try {
19
19
  MissingError.check(null, "argument");
20
- throw "The method did not throw an error.";
20
+ throw new Error("The method did not throw an error.");
21
21
  } catch (e) {
22
22
  expect(e).to.be.an.instanceof(MissingError);
23
23
  expect(e.argumentName).to.equal("argument");
@@ -27,7 +27,7 @@ describe("MissingError#check", () => {
27
27
  it("should throw a MissingError given a 'null' argument value: (null, null, \"Lawyer#argue\").", () => {
28
28
  try {
29
29
  MissingError.check(null, null, "Lawyer#argue");
30
- throw "The method did not throw an error.";
30
+ throw new Error("The method did not throw an error.");
31
31
  } catch (e) {
32
32
  expect(e).to.be.an.instanceof(MissingError);
33
33
  expect(e.argumentName).to.be.null;
@@ -37,7 +37,7 @@ describe("MissingError#check", () => {
37
37
  it("should throw a MissingError given a 'null' argument value: (null).", () => {
38
38
  try {
39
39
  MissingError.check(null);
40
- throw "The method did not throw an error.";
40
+ throw new Error("The method did not throw an error.");
41
41
  } catch (e) {
42
42
  expect(e).to.be.an.instanceof(MissingError);
43
43
  expect(e.argumentName).to.be.undefined;
@@ -47,7 +47,7 @@ describe("MissingError#check", () => {
47
47
  it('should throw a MissingError given an \'undefined\' argument value: (undefined, "argument", "Lawyer#argue").', () => {
48
48
  try {
49
49
  MissingError.check(undefined, "argument", "Lawyer#argue");
50
- throw "The method did not throw an error.";
50
+ throw new Error("The method did not throw an error.");
51
51
  } catch (e) {
52
52
  expect(e).to.be.an.instanceof(MissingError);
53
53
  expect(e.argumentName).to.equal("argument");
@@ -57,7 +57,7 @@ describe("MissingError#check", () => {
57
57
  it("should throw a MissingError given an 'undefined' argument value: (undefined, \"argument\").", () => {
58
58
  try {
59
59
  MissingError.check(undefined, "argument");
60
- throw "The method did not throw an error.";
60
+ throw new Error("The method did not throw an error.");
61
61
  } catch (e) {
62
62
  expect(e).to.be.an.instanceof(MissingError);
63
63
  expect(e.argumentName).to.equal("argument");
@@ -67,7 +67,7 @@ describe("MissingError#check", () => {
67
67
  it("should throw a MissingError given an 'undefined' argument value: (undefined, null, \"Lawyer#argue\").", () => {
68
68
  try {
69
69
  MissingError.check(undefined, null, "Lawyer#argue");
70
- throw "The method did not throw an error.";
70
+ throw new Error("The method did not throw an error.");
71
71
  } catch (e) {
72
72
  expect(e).to.be.an.instanceof(MissingError);
73
73
  expect(e.argumentName).to.be.null;
@@ -77,7 +77,7 @@ describe("MissingError#check", () => {
77
77
  it("should throw a MissingError given an 'undefined' argument value: no arguments.", () => {
78
78
  try {
79
79
  MissingError.check(undefined);
80
- throw "The method did not throw an error.";
80
+ throw new Error("The method did not throw an error.");
81
81
  } catch (e) {
82
82
  expect(e).to.be.an.instanceof(MissingError);
83
83
  expect(e.argumentName).to.be.undefined;