14
14
namespace Laudis \Neo4j \TestkitBackend \Handlers ;
15
15
16
16
use Laudis \Neo4j \Databags \TransactionConfiguration ;
17
+ use Laudis \Neo4j \Exception \Neo4jException ;
17
18
use Laudis \Neo4j \TestkitBackend \Contracts \RequestHandlerInterface ;
18
19
use Laudis \Neo4j \TestkitBackend \Contracts \TestkitResponseInterface ;
19
20
use Laudis \Neo4j \TestkitBackend \MainRepository ;
20
21
use Laudis \Neo4j \TestkitBackend \Requests \SessionBeginTransactionRequest ;
22
+ use Laudis \Neo4j \TestkitBackend \Responses \DriverErrorResponse ;
21
23
use Laudis \Neo4j \TestkitBackend \Responses \TransactionResponse ;
24
+ use Psr \Log \LoggerInterface ;
22
25
use Symfony \Component \Uid \Uuid ;
23
26
24
27
/**
27
30
final class SessionBeginTransaction implements RequestHandlerInterface
28
31
{
29
32
private MainRepository $ repository ;
33
+ private LoggerInterface $ logger ;
30
34
31
- public function __construct (MainRepository $ repository )
35
+ public function __construct (MainRepository $ repository, LoggerInterface $ logger )
32
36
{
33
37
$ this ->repository = $ repository ;
38
+ $ this ->logger = $ logger ;
34
39
}
35
40
36
41
/**
@@ -51,7 +56,13 @@ public function handle($request): TestkitResponseInterface
51
56
}
52
57
53
58
// 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
+ }
55
66
$ id = Uuid::v4 ();
56
67
57
68
$ this ->repository ->addTransaction ($ id , $ transaction );
0 commit comments