您当前的位置: 首页 >  ar

知其黑、受其白

暂无认证

  • 5浏览

    0关注

    1250博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Laravel 异常错误信息处理

知其黑、受其白 发布时间:2021-02-04 18:35:41 ,浏览量:5

手动抛出错误
try{
	
	$num1 = 3;
	if ($num1 == 3) {
		throw new \Exception("自定义错误");
	}
}catch(\Exception $exception){
	info($exception->getMessage());
}
日志打印出了: 自定义错误
Laravel 异常错误信息处理
use Illuminate\Http\Exceptions\HttpResponseException;

/**
 * Laravel 异常错误信息处理
 * @author wgchen
 * @date 2022-2-14
 */
public function checkCrmLegal()
{
    throw (new HttpResponseException(response()->json([
        'status_code' => 422,
        'message' => 'asdf',
    ], 200)));
}

在这里插入图片描述

use Symfony\Component\HttpKernel\Exception\HttpException;

throw new HttpException(400, 'asdf');

在这里插入图片描述

关注
打赏
1665558895
查看更多评论
立即登录/注册

微信扫码登录

0.0503s