| 12345678910111213141516171819202122 |
- <?php
- namespace App\Exceptions;
- use Exception;
- use Illuminate\Http\Client\Response;
- class AsaasException extends Exception
- {
- public array $errors;
- public function __construct(Response $response)
- {
- $status = $response->status();
- $body = $response->json();
- $this->errors = $body['errors'] ?? [];
- $message = "Asaas API Error ($status): " . collect($this->errors)->pluck('description')->join(', ');
- parent::__construct($message, $status);
- }
- }
|