Skip to content

Commit e14d10a

Browse files
committed
made error handling more precise #63
1 parent 872bc99 commit e14d10a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Bolt/BoltUnmanagedTransaction.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
namespace Laudis\Neo4j\Bolt;
1515

1616
use Bolt\Bolt;
17+
use Bolt\error\MessageException;
1718
use Ds\Vector;
1819
use Exception;
1920
use Laudis\Neo4j\Contracts\FormatterInterface;
@@ -81,16 +82,25 @@ public function rollback(): void
8182
}
8283
}
8384

85+
/**
86+
* @throws Throwable
87+
*/
8488
public function run(string $statement, iterable $parameters = [])
8589
{
8690
return $this->runStatement(new Statement($statement, $parameters));
8791
}
8892

93+
/**
94+
* @throws Throwable
95+
*/
8996
public function runStatement(Statement $statement)
9097
{
9198
return $this->runStatements([$statement])->first();
9299
}
93100

101+
/**
102+
* @throws Throwable
103+
*/
94104
public function runStatements(iterable $statements): CypherList
95105
{
96106
/** @var Vector<T> $tbr */
@@ -104,7 +114,10 @@ public function runStatements(iterable $statements): CypherList
104114
/** @var array<array> $results */
105115
$results = $this->bolt->pullAll();
106116
} catch (Throwable $e) {
107-
throw new Neo4jException(new Vector([new Neo4jError('', $e->getMessage())]), $e);
117+
if ($e instanceof MessageException) {
118+
throw new Neo4jException(new Vector([new Neo4jError('', $e->getMessage())]), $e);
119+
}
120+
throw $e;
108121
}
109122
$tbr->push($this->formatter->formatBoltResult($meta, $results, $this->bolt));
110123
}

0 commit comments

Comments
 (0)