diff --git a/src/Exceptions/ApiException.php b/src/Exceptions/ApiException.php index 1d5d65b..c2d2d89 100644 --- a/src/Exceptions/ApiException.php +++ b/src/Exceptions/ApiException.php @@ -12,26 +12,21 @@ class ApiException extends Exception * 返回到接口的验证码 * @var int $response_code */ - protected $response_code = 0; + protected $response_code = 400000; /** * ApiException constructor. * @param string $message - * @param int $response_code * @param Throwable|null $previous */ - public function __construct( - $message, - $response_code = 400000, - Throwable $previous = null - ) { - parent::__construct($message, 0, $previous); - $this->response_code = $response_code; + public function __construct(string $message, Throwable $previous = null) + { + parent::__construct($message, $previous); } - public static function formException(Exception $e, $response_code = 400000) + public static function fromException(Exception $e) { - return new ApiException($e->getMessage(), $response_code, $e); + return new ApiException($e->getMessage(), $e); } /** diff --git a/src/Exceptions/ApiInvalidParamException.php b/src/Exceptions/ApiInvalidParamException.php index 2e96820..16282f2 100644 --- a/src/Exceptions/ApiInvalidParamException.php +++ b/src/Exceptions/ApiInvalidParamException.php @@ -4,8 +4,5 @@ namespace PdToolKit\Exceptions; class ApiInvalidParamException extends ApiException { - public function __construct($message, Throwable $previous = null) - { - parent::__construct($message, 400400, $previous); - } + protected $response_code = 400400; } \ No newline at end of file diff --git a/src/Exceptions/ApiSystemException.php b/src/Exceptions/ApiSystemException.php index 7e21c12..7853af9 100644 --- a/src/Exceptions/ApiSystemException.php +++ b/src/Exceptions/ApiSystemException.php @@ -2,10 +2,14 @@ namespace PdToolKit\Exceptions; +use Throwable; + class ApiSystemException extends ApiException { + protected $response_code = 400000; + public function __construct($message = "网络波动,稍后再试", Throwable $previous = null) { - parent::__construct($message, 400000, $previous); + parent::__construct($message, $previous); } } \ No newline at end of file