初始化本地仓库
This commit is contained in:
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
namespace core\exception;
|
||||
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use core\jwt\ex\JwtRefreshTokenExpiredException;
|
||||
use core\jwt\ex\JwtTokenExpiredException;
|
||||
use core\jwt\ex\JwtTokenInBlacklistException;
|
||||
use core\jwt\ex\JwtTokenInvalidException;
|
||||
use FastRoute\BadRouteException;
|
||||
use core\exception\handler\BaseException;
|
||||
use core\exception\handler\ServerErrorHttpException;
|
||||
use think\exception\ValidateException;
|
||||
use Throwable;
|
||||
use Webman\Exception\ExceptionHandler;
|
||||
use Webman\Http\Request;
|
||||
use Webman\Http\Response;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
public $dontReport = [];
|
||||
protected int $statusCode = 200;
|
||||
protected array $header = [];
|
||||
protected int $errorCode = -1;
|
||||
protected string $errorMessage = 'no error';
|
||||
protected array $responseData = [];
|
||||
protected array $config = [];
|
||||
protected string $error = 'no error';
|
||||
|
||||
public function report(Throwable $exception)
|
||||
{
|
||||
$this->dontReport = config('core.exception.app.handler.dont_report', []);
|
||||
parent::report($exception);
|
||||
}
|
||||
|
||||
public function render(Request $request, Throwable $exception): Response
|
||||
{
|
||||
// Apidoc异常处理响应
|
||||
// if ($exception instanceof \hg\apidoc\exception\HttpException) {
|
||||
// return response(json_encode([
|
||||
// "code" => $exception->getCode(),
|
||||
// "message" => $exception->getMessage(),
|
||||
// ], JSON_UNESCAPED_UNICODE), $exception->getStatusCode());
|
||||
// }
|
||||
|
||||
// 处理Laravel验证异常
|
||||
if ($exception instanceof ValidationException) {
|
||||
$errors = $exception->errors();
|
||||
return json([
|
||||
'code' => 422,
|
||||
'message' => 'Validation failed',
|
||||
'data' => $errors,
|
||||
], 422);
|
||||
}
|
||||
|
||||
$this->initializeConfig();
|
||||
$this->addRequestInfoToResponse($request);
|
||||
$this->processException($exception);
|
||||
$this->addDebugInfoToResponse($exception);
|
||||
$this->triggerEvents($exception);
|
||||
|
||||
return $this->buildResponse();
|
||||
}
|
||||
|
||||
protected function initializeConfig(): void
|
||||
{
|
||||
$this->config = array_merge($this->config, config('core.exception.app.handler', []));
|
||||
}
|
||||
|
||||
protected function addRequestInfoToResponse(Request $request): void
|
||||
{
|
||||
$this->responseData = array_merge($this->responseData, [
|
||||
'domain' => $request->host(),
|
||||
'method' => $request->method(),
|
||||
'request_url' => $request->method() . ' ' . $request->uri(),
|
||||
'timestamp' => date('Y-m-d H:i:s'),
|
||||
'client_ip' => $request->getRealIp(),
|
||||
'request_param' => $request->all(),
|
||||
]);
|
||||
}
|
||||
|
||||
protected function processException(Throwable $e): void
|
||||
{
|
||||
if ($e instanceof BaseException) {
|
||||
$this->handleBaseException($e);
|
||||
} else {
|
||||
$this->handleOtherExceptions($e);
|
||||
}
|
||||
}
|
||||
|
||||
protected function handleBaseException(BaseException $e): void
|
||||
{
|
||||
$this->statusCode = $e->statusCode;
|
||||
$this->header = $e->header;
|
||||
$this->errorCode = $e->errorCode;
|
||||
$this->errorMessage = $e->errorMessage;
|
||||
$this->error = $e->error;
|
||||
|
||||
if (isset($e->data)) {
|
||||
$this->responseData = array_merge($this->responseData, $e->data);
|
||||
}
|
||||
}
|
||||
|
||||
protected function handleOtherExceptions(Throwable $e): void
|
||||
{
|
||||
$status = $this->config['status'];
|
||||
$this->errorMessage = $e->getMessage();
|
||||
switch (true) {
|
||||
case $e instanceof BadRouteException:
|
||||
$this->statusCode = $status['route'] ?? 404;
|
||||
break;
|
||||
case $e instanceof ValidateException:
|
||||
$this->statusCode = $status['validate'] ?? 400;
|
||||
break;
|
||||
case $e instanceof JwtTokenInBlacklistException:
|
||||
case $e instanceof JwtTokenInvalidException:
|
||||
$this->statusCode = $status['jwt_token'] ?? 401;
|
||||
break;
|
||||
case $e instanceof JwtTokenExpiredException:
|
||||
$this->statusCode = $status['jwt_token_expired'] ?? 401;
|
||||
break;
|
||||
case $e instanceof JwtRefreshTokenExpiredException:
|
||||
$this->statusCode = $status['jwt_refresh_token_expired'] ?? 401;
|
||||
break;
|
||||
case $e instanceof \InvalidArgumentException:
|
||||
$this->statusCode = $status['invalid_argument'] ?? 415;
|
||||
$this->errorMessage = '预期参数配置异常:' . $e->getMessage();
|
||||
break;
|
||||
case $e instanceof ServerErrorHttpException:
|
||||
$this->statusCode = 500;
|
||||
$this->errorCode=-1;
|
||||
break;
|
||||
default:
|
||||
$this->statusCode = $status['server_error'] ?? 500;
|
||||
$this->errorMessage = 'Internal Server Error';
|
||||
$this->error = $e->getMessage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected function addDebugInfoToResponse(Throwable $e): void
|
||||
{
|
||||
if (config('app.debug', false)) {
|
||||
$this->responseData['error_message'] = $e->getMessage();
|
||||
$this->responseData['error_trace'] = explode("\n", $e->getTraceAsString());
|
||||
$this->responseData['file'] = $e->getFile();
|
||||
$this->responseData['line'] = $e->getLine();
|
||||
}
|
||||
}
|
||||
|
||||
protected function triggerEvents(Throwable $e): void
|
||||
{
|
||||
$this->triggerNotifyEvent($e);
|
||||
$this->triggerTraceEvent($e);
|
||||
}
|
||||
|
||||
protected function triggerNotifyEvent(Throwable $e): void
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected function triggerTraceEvent(Throwable $e): void
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected function buildResponse(): Response
|
||||
{
|
||||
$bodyKey = array_keys($this->config['body']);
|
||||
$bodyValue = array_values($this->config['body']);
|
||||
|
||||
// 当HTTP状态码为错误状态时,确保code不为0
|
||||
$code = $this->errorCode ?: ($bodyValue[0] ?? 0);
|
||||
if (($this->statusCode >= 400 || $this->statusCode < 100) && $code === 0) {
|
||||
$code = -1;
|
||||
}
|
||||
|
||||
$responseBody = [
|
||||
$bodyKey[0] ?? 'code' => $code,
|
||||
$bodyKey[1] ?? 'msg' => $this->errorMessage,
|
||||
$bodyKey[2] ?? 'data' => $this->responseData,
|
||||
];
|
||||
|
||||
$header = array_merge(['Content-Type' => 'application/json;charset=utf-8'], $this->header);
|
||||
return new Response($this->statusCode, $header, json_encode($responseBody));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/**
|
||||
*+------------------
|
||||
* madong
|
||||
*+------------------
|
||||
* Copyright (c) https://gitee.com/motion-code All rights reserved.
|
||||
*+------------------
|
||||
* Author: Mr. April (405784684@qq.com)
|
||||
*+------------------
|
||||
* Official Website: https://madong.tech
|
||||
*/
|
||||
|
||||
namespace core\exception;
|
||||
|
||||
|
||||
class Logger extends \support\Log
|
||||
{
|
||||
/**
|
||||
* 处理静态方法调用
|
||||
*
|
||||
* @param string $name 方法名
|
||||
* @param array $arguments 参数数组
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function __callStatic(string $name, array $arguments)
|
||||
{
|
||||
if ($name === 'error') {
|
||||
return self::handleErrorLog($arguments);
|
||||
}
|
||||
|
||||
return parent::__callStatic($name, $arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理错误日志记录
|
||||
*
|
||||
* @param array $arguments 原始参数
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected static function handleErrorLog(array $arguments): mixed
|
||||
{
|
||||
$config = config('core.exception.app.exception_handler', []);
|
||||
$original = $arguments[1] ?? [];
|
||||
|
||||
$logData = self::prepareLogData($original);
|
||||
$logData['message'] = current($arguments);
|
||||
|
||||
if (!empty(request())) {
|
||||
self::enrichRequestData($logData);
|
||||
}
|
||||
|
||||
$logData['environment'] = self::determineEnvironment($logData['domain'] ?? '', $config);
|
||||
|
||||
return parent::__callStatic('error', [$logData['message'], $logData]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 准备日志数据
|
||||
*
|
||||
* @param array $original 原始数据
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function prepareLogData(array $original): array
|
||||
{
|
||||
return [
|
||||
'error' => $original['error'] ?? '--',
|
||||
'domain' => $original['domain'] ?? '--',
|
||||
'request_url' => $original['request_url'] ?? '--',
|
||||
'client_ip' => $original['client_ip'] ?? '127.0.0.1',
|
||||
'timestamp' => $original['timestamp'] ?? date('Y-m-d H:i:s'),
|
||||
'request_param' => $original['request_param'] ?? [],
|
||||
'file' => $original['file'] ?? '--',
|
||||
'line' => $original['line'] ?? '--',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 丰富请求相关数据
|
||||
*
|
||||
* @param array $logData 日志数据引用
|
||||
*/
|
||||
protected static function enrichRequestData(array &$logData): void
|
||||
{
|
||||
$logData['domain'] = request()->host();
|
||||
$logData['request_url'] = request()->uri();
|
||||
$logData['client_ip'] = request()->getRealIp();
|
||||
$logData['request_param'] = request()->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* 确定当前环境
|
||||
*
|
||||
* @param string $domain 当前域名
|
||||
* @param array $config 配置数组
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected static function determineEnvironment(string $domain, array $config): string
|
||||
{
|
||||
$environments = [
|
||||
'dev' => '测试环境',
|
||||
'pre' => '预发环境',
|
||||
'prod' => '正式环境',
|
||||
];
|
||||
|
||||
foreach ($environments as $key => $title) {
|
||||
if (!empty($config['domain'][$key]) && str_contains($domain, $config['domain'][$key])) {
|
||||
return $title;
|
||||
}
|
||||
}
|
||||
|
||||
return '开发环境';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'enable' => true,
|
||||
// 异常配置
|
||||
'handler' => [
|
||||
// 不需要记录错误日志
|
||||
'dont_report' => [
|
||||
\core\exception\handler\AccessDeniedHttpException::class,
|
||||
\core\exception\handler\BadRequestHttpException::class,
|
||||
\core\exception\handler\ForbiddenHttpException::class,
|
||||
\core\exception\handler\NotFoundHttpException::class,
|
||||
\core\exception\handler\ServerErrorHttpException::class,
|
||||
\core\exception\handler\TooManyRequestsHttpException::class,
|
||||
\core\exception\handler\UnauthorizedHttpException::class,
|
||||
],
|
||||
// 自定义HTTP状态码
|
||||
'status' => [
|
||||
'validate' => 400, // 验证器异常
|
||||
'jwt_token' => 401, // 认证失败
|
||||
'jwt_token_expired' => 401, // 访问令牌过期
|
||||
'jwt_refresh_token_expired' => 402, // 刷新令牌过期
|
||||
'server_error' => 500, // 服务器内部错误
|
||||
],
|
||||
// 自定义响应消息
|
||||
'body' => [
|
||||
'code' => 0,
|
||||
'msg' => '服务器内部异常',
|
||||
'data' => null,
|
||||
],
|
||||
/** 异常报警域名标题 */
|
||||
'domain' => [
|
||||
'dev' => 'dev-api.madong.tech', // 开发环境
|
||||
'dev' => 'dev-api.madong.tech', // 测试环境
|
||||
'pre' => 'pre-api.madong.tech', // 预发环境
|
||||
'prod' => 'api.madong.tech', // 生产环境
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
*+------------------
|
||||
* madong
|
||||
*+------------------
|
||||
* Copyright (c) https://gitee.com/motion-code All rights reserved.
|
||||
*+------------------
|
||||
* Author: Mr. April (405784684@qq.com)
|
||||
*+------------------
|
||||
* Official Website: https://madong.tech
|
||||
*/
|
||||
|
||||
namespace core\exception\handler;
|
||||
|
||||
|
||||
use core\exception\handler\BaseException;
|
||||
|
||||
class AccessDeniedHttpException extends BaseException
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public int $statusCode = 403;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $errorMessage = '当前操作没有权限执行,请检查您的账户权限';
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
*+------------------
|
||||
* madong
|
||||
*+------------------
|
||||
* Copyright (c) https://gitee.com/motion-code All rights reserved.
|
||||
*+------------------
|
||||
* Author: Mr. April (405784684@qq.com)
|
||||
*+------------------
|
||||
* Official Website: http://www.madong.tech
|
||||
*/
|
||||
|
||||
namespace core\exception\handler;
|
||||
|
||||
use core\exception\handler\BaseException;
|
||||
|
||||
/**
|
||||
* 自定义异常类
|
||||
*
|
||||
* @author Mr.April
|
||||
* @since 1.0
|
||||
*/
|
||||
class AdminException extends BaseException
|
||||
{
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public int $statusCode = -1;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public int $errorCode = -1;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
*+------------------
|
||||
* madong
|
||||
*+------------------
|
||||
* Copyright (c) https://gitee.com/motion-code All rights reserved.
|
||||
*+------------------
|
||||
* Author: Mr. April (405784684@qq.com)
|
||||
*+------------------
|
||||
* Official Website: https://madong.tech
|
||||
*/
|
||||
|
||||
namespace core\exception\handler;
|
||||
|
||||
|
||||
use core\exception\handler\BaseException;
|
||||
|
||||
class BadRequestHttpException extends BaseException
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public int $statusCode = 400;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $errorMessage = '请求参数错误,请检查后重试';
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
*+------------------
|
||||
* madong
|
||||
*+------------------
|
||||
* Copyright (c) https://gitee.com/motion-code All rights reserved.
|
||||
*+------------------
|
||||
* Author: Mr. April (405784684@qq.com)
|
||||
*+------------------
|
||||
* Official Website: https://madong.tech
|
||||
*/
|
||||
|
||||
namespace core\exception\handler;
|
||||
|
||||
class BaseException extends \Exception
|
||||
{
|
||||
/**
|
||||
* HTTP Response Status Code.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public int $statusCode = 400;
|
||||
|
||||
/**
|
||||
* HTTP Response Header.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public array $header = [
|
||||
'Access-Control-Allow-Origin' => '*',
|
||||
'Access-Control-Allow-Credentials' => 'true',
|
||||
'Access-Control-Allow-Headers' => 'Authorization,Content-Type,If-Match,If-Modified-Since,If-None-Match,If-Unmodified-Since,X-Requested-With,Origin',
|
||||
'Access-Control-Allow-Methods' => 'GET,POST,PUT,DELETE,OPTIONS',
|
||||
];
|
||||
|
||||
/**
|
||||
* Business Error code.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public int $errorCode = 0;
|
||||
|
||||
/**
|
||||
* Business Error message.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public string $errorMessage = 'The requested resource is not available or not exists';
|
||||
|
||||
/**
|
||||
* Business data.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public mixed $data = [];
|
||||
|
||||
/**
|
||||
* Detail Log Error message.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public string $error = '';
|
||||
|
||||
/**
|
||||
* BaseException constructor.
|
||||
*
|
||||
* @param string $errorMessage
|
||||
* @param array $params
|
||||
* @param string $error
|
||||
*/
|
||||
public function __construct(string $errorMessage = '', array $params = [], string $error = '')
|
||||
{
|
||||
$errorMessage = __($errorMessage ?: $this->errorMessage);// 翻译错误信息
|
||||
$this->errorMessage = $errorMessage;
|
||||
$this->error = $error;
|
||||
if (!empty($params)) {
|
||||
$this->statusCode = $params['statusCode'] ?? $this->statusCode;
|
||||
$this->header = array_merge($this->header, $params['header'] ?? []);
|
||||
$this->errorCode = $params['errorCode'] ?? $this->errorCode;
|
||||
$this->data = $params['data'] ?? $this->data;
|
||||
}
|
||||
parent::__construct($errorMessage, $this->errorCode);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace core\exception\handler;
|
||||
|
||||
|
||||
class CaptchaException extends \RuntimeException
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
*+------------------
|
||||
* madong
|
||||
*+------------------
|
||||
* Copyright (c) https://gitee.com/motion-code All rights reserved.
|
||||
*+------------------
|
||||
* Author: Mr. April (405784684@qq.com)
|
||||
*+------------------
|
||||
* Official Website: http://www.madong.tech
|
||||
*/
|
||||
|
||||
namespace core\exception\handler;
|
||||
|
||||
use core\exception\handler\BaseException;
|
||||
|
||||
/**
|
||||
* 公共异常类
|
||||
*
|
||||
* @author Mr.April
|
||||
* @since 1.0
|
||||
*/
|
||||
class CommonException extends BaseException
|
||||
{
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public int $statusCode = -1;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
*+------------------
|
||||
* madong
|
||||
*+------------------
|
||||
* Copyright (c) https://gitee.com/motion-code All rights reserved.
|
||||
*+------------------
|
||||
* Author: Mr. April (405784684@qq.com)
|
||||
*+------------------
|
||||
* Official Website: https://madong.tech
|
||||
*/
|
||||
|
||||
namespace core\exception\handler;
|
||||
|
||||
use core\exception\handler\BaseException;
|
||||
|
||||
class ForbiddenHttpException extends BaseException
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public int $statusCode = 403;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $errorMessage = '对不起,您没有该接口访问权限,请联系管理员';
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
*+------------------
|
||||
* madong
|
||||
*+------------------
|
||||
* Copyright (c) https://gitee.com/motion-code All rights reserved.
|
||||
*+------------------
|
||||
* Author: Mr. April (405784684@qq.com)
|
||||
*+------------------
|
||||
* Official Website: https://madong.tech
|
||||
*/
|
||||
|
||||
namespace core\exception\handler;
|
||||
|
||||
use core\exception\handler\BaseException;
|
||||
|
||||
class NotFoundHttpException extends BaseException
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public int $statusCode = 404;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $errorMessage = '请求的资源不存在或已被删除';
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
*+------------------
|
||||
* madong
|
||||
*+------------------
|
||||
* Copyright (c) https://gitee.com/motion-code All rights reserved.
|
||||
*+------------------
|
||||
* Author: Mr. April (405784684@qq.com)
|
||||
*+------------------
|
||||
* Official Website: http://www.madong.tech
|
||||
*/
|
||||
|
||||
namespace core\exception\handler;
|
||||
|
||||
use core\exception\handler\BaseException;
|
||||
|
||||
/**
|
||||
* 插件异常类
|
||||
*
|
||||
* @author Mr.April
|
||||
* @since 1.0
|
||||
*/
|
||||
class PluginException extends BaseException
|
||||
{
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public int $statusCode = -1;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
*+------------------
|
||||
* madong
|
||||
*+------------------
|
||||
* Copyright (c) https://gitee.com/motion-code All rights reserved.
|
||||
*+------------------
|
||||
* Author: Mr. April (405784684@qq.com)
|
||||
*+------------------
|
||||
* Official Website: https://madong.tech
|
||||
*/
|
||||
|
||||
namespace core\exception\handler;
|
||||
|
||||
use core\exception\handler\BaseException;
|
||||
|
||||
class ServerErrorHttpException extends BaseException
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public int $statusCode = 500;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $errorMessage = '服务器内部错误,请稍后再试';
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
*+------------------
|
||||
* madong
|
||||
*+------------------
|
||||
* Copyright (c) https://gitee.com/motion-code All rights reserved.
|
||||
*+------------------
|
||||
* Author: Mr. April (405784684@qq.com)
|
||||
*+------------------
|
||||
* Official Website: https://madong.tech
|
||||
*/
|
||||
|
||||
namespace core\exception\handler;
|
||||
|
||||
|
||||
use core\exception\handler\BaseException;
|
||||
|
||||
class TooManyRequestsHttpException extends BaseException
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public int $statusCode = 429;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $errorMessage = '请求过于频繁,请稍后再试';
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
*+------------------
|
||||
* madong
|
||||
*+------------------
|
||||
* Copyright (c) https://gitee.com/motion-code All rights reserved.
|
||||
*+------------------
|
||||
* Author: Mr. April (405784684@qq.com)
|
||||
*+------------------
|
||||
* Official Website: https://madong.tech
|
||||
*/
|
||||
|
||||
namespace core\exception\handler;
|
||||
|
||||
use core\exception\handler\BaseException;
|
||||
|
||||
class UnauthorizedHttpException extends BaseException
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public int $statusCode = 401;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $errorMessage = '未经授权的访问,请先登录';
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
*+------------------
|
||||
* madong
|
||||
*+------------------
|
||||
* Copyright (c) https://gitee.com/motion-code All rights reserved.
|
||||
*+------------------
|
||||
* Author: Mr. April (405784684@qq.com)
|
||||
*+------------------
|
||||
* Official Website: http://www.madong.tech
|
||||
*/
|
||||
|
||||
namespace core\exception\handler;
|
||||
|
||||
use core\exception\handler\BaseException;
|
||||
|
||||
/**
|
||||
* 上传异常类
|
||||
*
|
||||
* @author Mr.April
|
||||
* @since 1.0
|
||||
*/
|
||||
class UploadException extends BaseException
|
||||
{
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public int $statusCode = -1;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
*+------------------
|
||||
* madong
|
||||
*+------------------
|
||||
* Copyright (c) https://gitee.com/motion-code All rights reserved.
|
||||
*+------------------
|
||||
* Author: Mr. April (405784684@qq.com)
|
||||
*+------------------
|
||||
* Official Website: http://www.madong.tech
|
||||
*/
|
||||
|
||||
namespace core\exception\handler;
|
||||
|
||||
use core\exception\handler\BaseException;
|
||||
|
||||
/**
|
||||
* 验证异常类
|
||||
*
|
||||
* @author Mr.April
|
||||
* @since 1.0
|
||||
*/
|
||||
class ValidationException extends BaseException
|
||||
{
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public int $statusCode = 400;
|
||||
|
||||
|
||||
public int $errorCode=422;
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user