Laravel ->Exceptions ->ApiException 自定义错误异常的封装_Common

 

<?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

 

throw new ApiException("服务器错误", 5000);

Laravel ->Exceptions ->ApiException 自定义错误异常的封装_Common_03