File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -89,10 +89,12 @@ public function execute(): void
8989 }
9090
9191 throw new UnableToCatchException (
92- $ expectedClass . ': ' . $ e ->getMessage ()
92+ $ expectedClass . ': ' . $ e ->getMessage (),
93+ 0 ,
94+ $ e
9395 );
9496 }
95-
97+
9698 if ($ signature [0 ]['type ' ] !== 'void ' ) {
9799 $ this ->pushToOperandStack ($ return );
98100 }
Original file line number Diff line number Diff line change @@ -82,7 +82,9 @@ public function execute(): void
8282 }
8383
8484 throw new UnableToCatchException (
85- $ expectedClass . ': ' . $ e ->getMessage ()
85+ $ expectedClass . ': ' . $ e ->getMessage (),
86+ 0 ,
87+ $ e
8688 );
8789 }
8890
Original file line number Diff line number Diff line change 11<?php
22namespace PHPJava \Tests ;
33
4+ use PHPJava \Exceptions \UnableToCatchException ;
5+ use PHPJava \Packages \java \lang \IndexOutOfBoundsException ;
46use PHPUnit \Framework \TestCase ;
57
68class TryCatchTest extends Base
@@ -37,7 +39,7 @@ public function testPassthroughCatchStatement()
3739 );
3840 }
3941
40- public function testImitationThroExceptionw ()
42+ public function testImitationThrowException ()
4143 {
4244 $ result = $ this ->initiatedJavaClasses ['TryCatchTest ' ]
4345 ->getInvoker ()
@@ -50,4 +52,24 @@ public function testImitationThroExceptionw()
5052 $ result
5153 );
5254 }
55+
56+ public function testImitationThrownExceptionHasPreviousException ()
57+ {
58+ try {
59+ $ result = $ this ->initiatedJavaClasses ['TryCatchTest ' ]
60+ ->getInvoker ()
61+ ->getStatic ()
62+ ->getMethods ()
63+ ->call ('testImitationThrownExceptionHasPreviousException ' );
64+ } catch (UnableToCatchException $ e ) {
65+ $ this ->assertInstanceOf (
66+ IndexOutOfBoundsException::class,
67+ $ e ->getPrevious ()
68+ );
69+ $ this ->assertEquals (
70+ 'String index out of range: -1 ' ,
71+ $ e ->getPrevious ()->getMessage ()
72+ );
73+ }
74+ }
5375}
Original file line number Diff line number Diff line change @@ -33,4 +33,9 @@ public static int testImitationThrowException()
3333
3434 return 1 ;
3535 }
36+
37+ public static void testImitationThrownExceptionHasPreviousException ()
38+ {
39+ "" .charAt (-1 );
40+ }
3641}
You can’t perform that action at this time.
0 commit comments