@@ -63,8 +63,8 @@ public function preConditionContract(MethodInvocation $invocation)
63
63
64
64
try {
65
65
$ this ->ensureContractSatisfied ($ object , $ scope , $ args , $ annotation );
66
- } catch (DomainException $ e ) {
67
- throw new ContractViolation ($ invocation , $ annotation ->value , $ e-> getPrevious () );
66
+ } catch (\ Exception $ e ) {
67
+ throw new ContractViolation ($ invocation , $ annotation ->value , $ e );
68
68
}
69
69
}
70
70
}
@@ -97,8 +97,8 @@ public function postConditionContract(MethodInvocation $invocation)
97
97
98
98
try {
99
99
$ this ->ensureContractSatisfied ($ object , $ class ->name , $ args , $ annotation );
100
- } catch (DomainException $ e ) {
101
- throw new ContractViolation ($ invocation , $ annotation ->value , $ e-> getPrevious () );
100
+ } catch (\ Exception $ e ) {
101
+ throw new ContractViolation ($ invocation , $ annotation ->value , $ e );
102
102
}
103
103
}
104
104
@@ -133,8 +133,8 @@ public function invariantContract(MethodInvocation $invocation)
133
133
134
134
try {
135
135
$ this ->ensureContractSatisfied ($ object , $ class ->name , $ args , $ annotation );
136
- } catch (DomainException $ e ) {
137
- throw new ContractViolation ($ invocation , $ annotation ->value , $ e-> getPrevious () );
136
+ } catch (\ Exception $ e ) {
137
+ throw new ContractViolation ($ invocation , $ annotation ->value , $ e );
138
138
}
139
139
}
140
140
@@ -162,16 +162,13 @@ private function ensureContractSatisfied($instance, $scope, array $args, $annota
162
162
}
163
163
$ instance = is_object ($ instance ) ? $ instance : null ;
164
164
165
- try {
166
- $ invocationResult = $ invoker ->bindTo ($ instance , $ scope )->__invoke ($ args , $ annotation ->value );
167
- } catch (\Exception $ e ) {
168
- throw new DomainException ("" , 0 , $ e );
169
- }
165
+ $ invocationResult = $ invoker ->bindTo ($ instance , $ scope )->__invoke ($ args , $ annotation ->value );
170
166
171
167
// we accept as a result only true or null
172
168
// null may be a result of assertions from beberlei/assert which passed
173
169
if ($ invocationResult !== null && $ invocationResult !== true ) {
174
- throw new DomainException ();
170
+ $ errorMessage = 'Invalid return value received from the assertion body, only boolean or void accepted ' ;
171
+ throw new DomainException ($ errorMessage );
175
172
}
176
173
}
177
174
0 commit comments