// +---------------------------------------------------------------------- declare(strict_types=1); namespace crmeb\exceptions; /** * 业务异常 * 用于业务逻辑中的非正常流程中断 * Class BusinessException * @package crmeb\exceptions */ class BusinessException extends \RuntimeException { /** * 错误码 * @var int */ protected int $errorCode = 0; /** * 附加数据 * @var array */ protected array $extra = []; public function __construct(string $message = '', int $code = 0, int $errorCode = 0, array $extra = [], ?\Throwable $previous = null) { parent::__construct($message, $code, $previous); $this->errorCode = $errorCode; $this->extra = $extra; } /** * 获取错误码 * @return int */ public function getErrorCode(): int { return $this->errorCode; } /** * 获取附加数据 * @return array */ public function getExtra(): array { return $this->extra; } }