@@ -63,8 +63,8 @@ public function preConditionContract(MethodInvocation $invocation)
6363
6464 try {
6565 $ 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 );
6868 }
6969 }
7070 }
@@ -97,8 +97,8 @@ public function postConditionContract(MethodInvocation $invocation)
9797
9898 try {
9999 $ 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 );
102102 }
103103 }
104104
@@ -133,8 +133,8 @@ public function invariantContract(MethodInvocation $invocation)
133133
134134 try {
135135 $ 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 );
138138 }
139139 }
140140
@@ -162,16 +162,13 @@ private function ensureContractSatisfied($instance, $scope, array $args, $annota
162162 }
163163 $ instance = is_object ($ instance ) ? $ instance : null ;
164164
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 );
170166
171167 // we accept as a result only true or null
172168 // null may be a result of assertions from beberlei/assert which passed
173169 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 );
175172 }
176173 }
177174
0 commit comments