Skip to content

Commit eab2685

Browse files
committed
Add default constructor for JsonApiError trait
1 parent 72f2436 commit eab2685

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Exception/Concerns/JsonApiError.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ trait JsonApiError
88
{
99
public array $error = [];
1010

11+
public function __construct(array|string $message = '')
12+
{
13+
if (is_array($message)) {
14+
$this->error = $message;
15+
$message = $this->error['detail'] ?? '';
16+
}
17+
18+
parent::__construct($message);
19+
}
20+
1121
public function source(array $source): static
1222
{
1323
$this->error['source'] = $source;

0 commit comments

Comments
 (0)