/
error.js
59 lines (50 loc) · 1.11 KB
/
error.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*!
* chai
* Copyright(c) 2011-2012 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/
/*!
* Main export
*/
module.exports = AssertionError;
/**
* # AssertionError (constructor)
*
* Create a new assertion error based on the Javascript
* `Error` prototype.
*
* **Options**
* - message
* - actual
* - expected
* - operator
* - startStackFunction
*
* @param {Object} options
* @api public
*/
function AssertionError (options) {
options = options || {};
this.message = options.message;
this.actual = options.actual;
this.expected = options.expected;
this.operator = options.operator;
if (options.stackStartFunction && Error.captureStackTrace) {
var stackStartFunction = options.stackStartFunction;
Error.captureStackTrace(this, stackStartFunction);
}
}
/*!
* Inherit from Error
*/
AssertionError.prototype = Object.create(Error.prototype);
AssertionError.prototype.name = 'AssertionError';
AssertionError.prototype.constructor = AssertionError;
/**
* # toString()
*
* Override default to string method
*/
AssertionError.prototype.toString = function() {
return this.message;
};