12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace app\common\exception;
- use Exception;
- /**
- * 业务异常类
- * 用于服务层抛出业务相关的异常
- */
- class BusinessException extends Exception
- {
- /**
- * 错误码
- * @var int
- */
- protected $errorCode;
- /**
- * 错误数据
- * @var mixed
- */
- protected $errorData;
- /**
- * 构造函数
- * @param string $message 错误消息
- * @param int $errorCode 错误码,默认为0
- * @param mixed $errorData 错误相关数据
- */
- public function __construct($message = '', $errorCode = 0, $errorData = null)
- {
- $this->errorCode = $errorCode;
- $this->errorData = $errorData;
- parent::__construct($message, $errorCode);
- }
- /**
- * 获取错误码
- * @return int
- */
- public function getErrorCode()
- {
- return $this->errorCode;
- }
- /**
- * 获取错误数据
- * @return mixed
- */
- public function getErrorData()
- {
- return $this->errorData;
- }
- }
|