@@ -8,9 +8,10 @@ var filter = require('array-filter');
8
8
var decorate = require ( './decorate' ) ;
9
9
10
10
11
- function Decorator ( receiver , config ) {
11
+ function Decorator ( receiver , onError , config ) {
12
12
this . receiver = receiver ;
13
13
this . config = config ;
14
+ this . onError = onError ;
14
15
this . signatures = map ( config . patterns , signature . parse ) ;
15
16
this . eagerEvaluation = ! ( config . modifyMessageOnRethrow || config . saveContextOnRethrow ) ;
16
17
}
@@ -56,31 +57,10 @@ Decorator.prototype.concreteAssert = function (invocation, context) {
56
57
try {
57
58
return func . apply ( thisObj , args . concat ( message ) ) ;
58
59
} catch ( e ) {
59
- throw this . errorToRethrow ( e , message , context ) ;
60
+ this . onError ( { error : e , originalMessage : message , powerAssertContext : context } ) ;
60
61
}
61
62
} ;
62
63
63
- Decorator . prototype . errorToRethrow = function ( e , originalMessage , context ) {
64
- if ( e . name !== 'AssertionError' ) {
65
- return e ;
66
- }
67
- if ( typeof this . receiver . AssertionError !== 'function' ) {
68
- return e ;
69
- }
70
- var f = new this . receiver . AssertionError ( {
71
- actual : e . actual ,
72
- expected : e . expected ,
73
- operator : e . operator ,
74
- message : e . message ,
75
- stackStartFunction : Decorator . prototype . concreteAssert
76
- } ) ;
77
- if ( this . config . saveContextOnRethrow ) {
78
- f . powerAssertContext = context ;
79
- }
80
- return f ;
81
- } ;
82
-
83
-
84
64
function numberOfArgumentsToCapture ( matcher ) {
85
65
var len = matcher . args . length ;
86
66
var lastArg ;
0 commit comments