File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77namespace Ouzo ;
88
99use Closure ;
10- use Exception ;
1110use Ouzo \Db \PDOExceptionExtractor ;
1211use Ouzo \Db \StatementExecutor ;
1312use Ouzo \Db \TransactionalProxy ;
1413use Ouzo \Utilities \Arrays ;
1514use PDO ;
1615use PDOException ;
16+ use Throwable ;
1717
1818
1919class Db
@@ -90,7 +90,7 @@ public function runInTransaction(Closure $callable): mixed
9090 $ result = call_user_func ($ callable );
9191 $ this ->commitTransaction ();
9292 return $ result ;
93- } catch (Exception $ e ) {
93+ } catch (Throwable $ e ) {
9494 $ this ->rollbackTransactionSilently ();
9595 throw $ e ;
9696 }
@@ -126,7 +126,7 @@ private function rollbackTransactionSilently(): void
126126 {
127127 try {
128128 $ this ->rollbackTransaction ();
129- } catch (Exception ) {
129+ } catch (Throwable ) {
130130 }
131131 }
132132
Original file line number Diff line number Diff line change @@ -62,10 +62,10 @@ public function runInTransactionShouldInvokeRollbackOnFailure()
6262 $ db ->dbHandle = $ dbHandle ;
6363
6464 //when
65- CatchException::when ($ db )->runInTransaction (fn () => throw new InvalidArgumentException ());
65+ CatchException::when ($ db )->runInTransaction (fn () => throw new Error ());
6666
6767 //then
68- CatchException::assertThat ()->isInstanceOf ('InvalidArgumentException ' );
68+ CatchException::assertThat ()->isInstanceOf ('Error ' );
6969 Mock::verify ($ dbHandle )->beginTransaction ();
7070 Mock::verify ($ dbHandle )->neverReceived ()->commitTransaction ();
7171 Mock::verify ($ dbHandle )->rollBack ();
You can’t perform that action at this time.
0 commit comments