|
14 | 14 | namespace Laudis\Neo4j\TestkitBackend\Handlers; |
15 | 15 |
|
16 | 16 | use Laudis\Neo4j\Databags\TransactionConfiguration; |
| 17 | +use Laudis\Neo4j\Exception\Neo4jException; |
| 18 | +use Laudis\Neo4j\TestkitBackend\Backend; |
17 | 19 | use Laudis\Neo4j\TestkitBackend\Contracts\RequestHandlerInterface; |
18 | 20 | use Laudis\Neo4j\TestkitBackend\Contracts\TestkitResponseInterface; |
19 | 21 | use Laudis\Neo4j\TestkitBackend\MainRepository; |
20 | 22 | use Laudis\Neo4j\TestkitBackend\Requests\SessionReadTransactionRequest; |
| 23 | +use Laudis\Neo4j\TestkitBackend\Responses\DriverErrorResponse; |
| 24 | +use Laudis\Neo4j\TestkitBackend\Responses\FrontendErrorResponse; |
| 25 | +use Laudis\Neo4j\TestkitBackend\Responses\ResultResponse; |
21 | 26 | use Laudis\Neo4j\TestkitBackend\Responses\RetryableTryResponse; |
22 | 27 | use Symfony\Component\Uid\Uuid; |
23 | 28 |
|
@@ -50,12 +55,21 @@ public function handle($request): TestkitResponseInterface |
50 | 55 | $config = $config->withMetaData($request->getTxMeta()); |
51 | 56 | } |
52 | 57 |
|
53 | | - // TODO - Create beginReadTransaction and beginWriteTransaction |
54 | | - $transaction = $session->beginTransaction(null, $config); |
55 | 58 | $id = Uuid::v4(); |
| 59 | + try { |
| 60 | + // TODO - Create beginReadTransaction and beginWriteTransaction |
| 61 | + $transaction = $session->beginTransaction(null, $config); |
56 | 62 |
|
57 | | - $this->repository->addTransaction($id, $transaction); |
58 | | - $this->repository->bindTransactionToSession($request->getSessionId(), $id); |
| 63 | + $this->repository->addTransaction($id, $transaction); |
| 64 | + $this->repository->bindTransactionToSession($request->getSessionId(), $id); |
| 65 | + } catch (Neo4jException $exception) { |
| 66 | + $this->repository->addRecords($id, new DriverErrorResponse( |
| 67 | + $id, |
| 68 | + $exception |
| 69 | + )); |
| 70 | + |
| 71 | + return new DriverErrorResponse($id, $exception); |
| 72 | + } |
59 | 73 |
|
60 | 74 | return new RetryableTryResponse($id); |
61 | 75 | } |
|
0 commit comments