nhance/app/Libraries/DigitMotor/DigitApiException.php
2026-07-21 09:32:13 +05:30

49 lines
1.1 KiB
PHP

<?php
namespace App\Libraries\DigitMotor;
use Exception;
class DigitApiException extends Exception
{
protected $digitCode;
protected $digitMessage;
protected $httpStatus;
protected $responseBody;
public function __construct(
string $message,
$digitCode = null,
int $httpStatus = 0,
$responseBody = null,
?Exception $previous = null
) {
parent::__construct($message, 0, $previous);
$this->digitCode = $digitCode;
$this->digitMessage = $message;
$this->httpStatus = $httpStatus;
$this->responseBody = $responseBody;
}
public function getDigitCode()
{
return $this->digitCode;
}
public function getHttpStatus(): int
{
return $this->httpStatus;
}
public function getResponseBody()
{
return $this->responseBody;
}
public function isInfraError(): bool
{
$code = (string) $this->digitCode;
return in_array($code, ['403', '999'], true) || in_array($this->httpStatus, [403], true);
}
}