ldc-crm/app/Exceptions/Api/V2/ApiErrorException.php
2021-07-28 14:18:47 +02:00

30 lines
620 B
PHP

<?php
namespace App\Exceptions\Api\V2;
use App\Enums\ApiError;
use Exception;
use Illuminate\Support\Facades\Log;
use Throwable;
class ApiErrorException extends Exception
{
protected $statusCode;
public function __construct(ApiError $error, int $statusCode = 400, Throwable $previous = null)
{
$this->statusCode = $statusCode;
parent::__construct($error->label, $error->value, $previous);
}
public function getStatusCode()
{
return $this->statusCode;
}
public function report()
{
Log::debug(sprintf('CRM API: %s', $this->getMessage()));
}
}