Laravel ->Exceptions ->ApiException 自定义错误异常的封装
原创
©著作权归作者所有:来自51CTO博客作者mp624183768的原创作品,请联系作者获取转载授权,否则将追究法律责任
![Laravel ->Exceptions ->ApiException 自定义错误异常的封装_Common](https://s2.51cto.com/images/blog/202303/17061256_64139468d74ca62633.png?x-oss-process=image/watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=,x-oss-process=image/resize,m_fixed,w_1184)
<?php
/**
* @Description
* @Date 2021-12-21 05:24
*/
namespace Modules\Common\Exceptions;
use Exception;
use Throwable;
class ApiException extends Exception
{
public function __construct($message = "", $code = 0, Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
}
// public function __construct(array $error_array, Throwable $previous = null)
// {
// parent::__construct($error_array['message'], $error_array['code'], $previous);
// }
}
![Laravel ->Exceptions ->ApiException 自定义错误异常的封装_服务器_02](https://s2.51cto.com/images/blog/202303/17061256_64139468cdf9536328.png?x-oss-process=image/watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=,x-oss-process=image/resize,m_fixed,w_1184)
throw new ApiException("服务器错误", 5000);
![Laravel ->Exceptions ->ApiException 自定义错误异常的封装_Common_03](https://s2.51cto.com/images/blog/202303/17061256_64139468e18c588199.png?x-oss-process=image/watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=,x-oss-process=image/resize,m_fixed,w_1184)