diff --git a/src/Exceptions/ErrorException.php b/src/Exceptions/ErrorException.php index a72a8666..9cb16d3f 100644 --- a/src/Exceptions/ErrorException.php +++ b/src/Exceptions/ErrorException.php @@ -11,16 +11,22 @@ final class ErrorException extends Exception /** * Creates a new Exception instance. * - * @param array{message: string|array, type: ?string, code: string|int|null} $contents + * @param array|string $contents + * @param int $statusCode */ - public function __construct(private readonly array $contents, private readonly int $statusCode) + public function __construct(private readonly array|string $contents, private readonly int $statusCode) { - $message = ($contents['message'] ?: (string) $this->contents['code']) ?: 'Unknown error'; + if(is_string($contents)) { + $message = $contents; + } else { + $message = ($contents['message'] ?: (string) $this->contents['code']) ?: 'Unknown error'; - if (is_array($message)) { - $message = implode(PHP_EOL, $message); + if (is_array($message)) { + $message = implode(PHP_EOL, $message); + } } + parent::__construct($message); }