Skip to content

Commit b6000cf

Browse files
committed
accounted for possible emtpy server error message
1 parent 8ba27a7 commit b6000cf

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/Databags/Neo4jError.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
final class Neo4jError
2727
{
2828
private string $code;
29-
private string $message;
29+
private ?string $message;
3030
private string $classification;
3131
private string $category;
3232
private string $title;
3333

34-
public function __construct(string $code, string $message, string $classification, string $category, string $title)
34+
public function __construct(string $code, ?string $message, string $classification, string $category, string $title)
3535
{
3636
$this->code = $code;
3737
$this->message = $message;
@@ -53,7 +53,7 @@ public static function fromMessageException(MessageException $e): self
5353
*
5454
* @throws InvalidArgumentException
5555
*/
56-
public static function fromMessageAndCode(string $code, string $message): Neo4jError
56+
public static function fromMessageAndCode(string $code, ?string $message): Neo4jError
5757
{
5858
$parts = explode('.', $code, 4);
5959
if (count($parts) < 4) {
@@ -74,7 +74,7 @@ public function getCode(): string
7474
/**
7575
* Returns the message of the error.
7676
*/
77-
public function getMessage(): string
77+
public function getMessage(): ?string
7878
{
7979
return $this->message;
8080
}

src/Exception/Neo4jException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ final class Neo4jException extends RuntimeException
3737
public function __construct(array $errors, Throwable $previous = null)
3838
{
3939
$error = $errors[0];
40-
$message = sprintf(self::MESSAGE_TEMPLATE, $error->getCode(), $error->getMessage());
40+
$message = sprintf(self::MESSAGE_TEMPLATE, $error->getCode(), $error->getMessage() ?? 'NULL');
4141
parent::__construct($message, 0, $previous);
4242
$this->errors = $errors;
4343
}
@@ -63,7 +63,7 @@ public function getNeo4jCode(): string
6363
return $this->errors[0]->getCode();
6464
}
6565

66-
public function getNeo4jMessage(): string
66+
public function getNeo4jMessage(): ?string
6767
{
6868
return $this->errors[0]->getMessage();
6969
}

testkit-backend/src/Responses/DriverErrorResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ final class DriverErrorResponse implements TestkitResponseInterface
2323
{
2424
private Uuid $id;
2525
private string $errorType;
26-
private string $message;
26+
private ?string $message;
2727

28-
public function __construct(Uuid $id, string $errorType, string $message)
28+
public function __construct(Uuid $id, string $errorType, ?string $message)
2929
{
3030
$this->id = $id;
3131
$this->errorType = $errorType;

0 commit comments

Comments
 (0)