1414namespace Laudis \Neo4j \TestkitBackend \Handlers ;
1515
1616use Laudis \Neo4j \Databags \TransactionConfiguration ;
17+ use Laudis \Neo4j \Exception \Neo4jException ;
1718use Laudis \Neo4j \TestkitBackend \Contracts \RequestHandlerInterface ;
1819use Laudis \Neo4j \TestkitBackend \Contracts \TestkitResponseInterface ;
1920use Laudis \Neo4j \TestkitBackend \MainRepository ;
2021use Laudis \Neo4j \TestkitBackend \Requests \SessionBeginTransactionRequest ;
22+ use Laudis \Neo4j \TestkitBackend \Responses \DriverErrorResponse ;
2123use Laudis \Neo4j \TestkitBackend \Responses \TransactionResponse ;
24+ use Psr \Log \LoggerInterface ;
2225use Symfony \Component \Uid \Uuid ;
2326
2427/**
2730final class SessionBeginTransaction implements RequestHandlerInterface
2831{
2932 private MainRepository $ repository ;
33+ private LoggerInterface $ logger ;
3034
31- public function __construct (MainRepository $ repository )
35+ public function __construct (MainRepository $ repository, LoggerInterface $ logger )
3236 {
3337 $ this ->repository = $ repository ;
38+ $ this ->logger = $ logger ;
3439 }
3540
3641 /**
@@ -51,7 +56,13 @@ public function handle($request): TestkitResponseInterface
5156 }
5257
5358 // TODO - Create beginReadTransaction and beginWriteTransaction
54- $ transaction = $ session ->beginTransaction (null , $ config );
59+ try {
60+ $ transaction = $ session ->beginTransaction (null , $ config );
61+ } catch (Neo4jException $ exception ) {
62+ $ this ->logger ->debug ($ exception ->__toString ());
63+
64+ return new DriverErrorResponse ($ request ->getSessionId (), $ exception );
65+ }
5566 $ id = Uuid::v4 ();
5667
5768 $ this ->repository ->addTransaction ($ id , $ transaction );
0 commit comments