mirror of
http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore.git
synced 2026-01-15 07:15:06 +08:00
36 lines
917 B
PHP
36 lines
917 B
PHP
<?php
|
|
|
|
namespace Singularity\HDK\Core\Exceptions;
|
|
|
|
use Hyperf\HttpMessage\Exception\HttpException;
|
|
use Singularity\HDK\Core\Constants\CommonErrorCode;
|
|
use Teapot\StatusCode\RFC\RFC7231;
|
|
use Throwable;
|
|
|
|
/**
|
|
* 902 数据库错误
|
|
*/
|
|
class DbException extends HttpException
|
|
{
|
|
public string $sql;
|
|
|
|
public function __construct(
|
|
int $code = CommonErrorCode::PROGRAM_SQL_ERROR,
|
|
?string $message = null,
|
|
string $sql = '',
|
|
Throwable $previous = null
|
|
) {
|
|
$this->sql = $sql;
|
|
if ($code == CommonErrorCode::FORBIDDEN) {
|
|
$previous_code = empty($previous) ? null : $previous->getCode();
|
|
$code = empty($previous_code) ? $code : $previous_code;
|
|
}
|
|
parent::__construct(
|
|
RFC7231::INTERNAL_SERVER_ERROR,
|
|
$message ?? CommonErrorCode::getMessage($code),
|
|
$code,
|
|
$previous
|
|
);
|
|
}
|
|
}
|