How to parse the Everyman\Neo4j\Exception

111 Views Asked by At

What is the best way to parse the Everyman\Neo4j\Exception ?

getMessage() method returns quite a long string and I am interested only in

[message] => ...
[exception] => ...

Parts of the string.

1

There are 1 best solutions below

0
On

If all you want is the first part of the message, without the response headers and body, you could try:

$message = trim(array_slice(explode('[', $exception->getMessage()), 0, 1));

The downside here is that it relies on knowing that everything up to the first square bracket is the message and the rest are body and headers. It also relies on the message itself not containing a square bracket.