Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/Exceptions/ErrorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,22 @@ final class ErrorException extends Exception
/**
* Creates a new Exception instance.
*
* @param array{message: string|array<int, string>, 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);
}

Expand Down
Loading