mirror of
http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore.git
synced 2026-01-15 07:15:06 +08:00
34 lines
869 B
PHP
34 lines
869 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;
|
|
|
|
use function Hyperf\Config\config;
|
|
|
|
/**
|
|
* 用户无权访问
|
|
*/
|
|
class Forbidden extends HttpException
|
|
{
|
|
public function __construct(
|
|
int $code = CommonErrorCode::FORBIDDEN,
|
|
?string $message = null,
|
|
Throwable $previous = null
|
|
) {
|
|
if ($code == CommonErrorCode::FORBIDDEN) {
|
|
$previous_code = $previous?->getCode();
|
|
$code = empty($previous_code) ? $code : $previous_code;
|
|
}
|
|
parent::__construct(
|
|
config('common.response.restful') ? RFC7231::FORBIDDEN : 200,
|
|
$message ?? CommonErrorCode::getMessage($code),
|
|
$code,
|
|
$previous
|
|
);
|
|
}
|
|
}
|