76 lines
1.8 KiB
PHP
76 lines
1.8 KiB
PHP
<?php
|
|
/**
|
|
* 商业使用授权协议
|
|
*
|
|
* Copyright (c) 2025 [云泽网]. 保留所有权利.
|
|
*
|
|
* 本软件仅供评估使用。任何商业用途必须获得书面授权许可。
|
|
* 未经授权商业使用本软件属于侵权行为,将承担法律责任。
|
|
*
|
|
* 授权购买请联系: 357099073@qq.com
|
|
* 官方网站: https://www.yunzer.cn
|
|
*
|
|
* 评估用户须知:
|
|
* 1. 禁止移除版权声明
|
|
* 2. 禁止用于生产环境
|
|
* 3. 禁止转售或分发
|
|
*/
|
|
|
|
namespace app;
|
|
|
|
use think\db\exception\DataNotFoundException;
|
|
use think\db\exception\ModelNotFoundException;
|
|
use think\exception\Handle;
|
|
use think\exception\HttpException;
|
|
use think\exception\HttpResponseException;
|
|
use think\exception\ValidateException;
|
|
use think\Response;
|
|
use Throwable;
|
|
|
|
/**
|
|
* 应用异常处理类
|
|
*/
|
|
class ExceptionHandle extends Handle
|
|
{
|
|
/**
|
|
* 不需要记录信息(日志)的异常类列表
|
|
* @var array
|
|
*/
|
|
protected $ignoreReport = [
|
|
HttpException::class,
|
|
HttpResponseException::class,
|
|
ModelNotFoundException::class,
|
|
DataNotFoundException::class,
|
|
ValidateException::class,
|
|
];
|
|
|
|
/**
|
|
* 记录异常信息(包括日志或者其它方式记录)
|
|
*
|
|
* @access public
|
|
* @param Throwable $exception
|
|
* @return void
|
|
*/
|
|
public function report(Throwable $exception): void
|
|
{
|
|
// 使用内置的方式记录异常日志
|
|
parent::report($exception);
|
|
}
|
|
|
|
/**
|
|
* Render an exception into an HTTP response.
|
|
*
|
|
* @access public
|
|
* @param \think\Request $request
|
|
* @param Throwable $e
|
|
* @return Response
|
|
*/
|
|
public function render($request, Throwable $e): Response
|
|
{
|
|
// 添加自定义异常处理机制
|
|
|
|
// 其他错误交给系统处理
|
|
return parent::render($request, $e);
|
|
}
|
|
}
|