Thinkphp5.0之異常處理

1.默認異常處理
在調試模式下,系統默認展現的錯誤頁面:
請輸入圖片描述php

異常處理接管app

1.修改config.phpurl

'app_debug' => false,
2.在配置文件裏添加以下代碼spa

// 異常處理handle類 留空使用 \think\exception\Handle
'exception_handle' => '\\app\\common\\exception\\Http',
3.添加錯誤異常模塊代碼:debug

<?php
namespace appcommonexception;
use thinkexceptionHandle;
class Http extends Handle
{調試

public function render(\Exception $e){
if(config('app_debug')){
//若是開啓debug則正常報錯
return parent::render($e);
}else{
//重定向頁面
header("Location:".url('index/index/index'));
}
}
}圖片

加完這些東西,就不會出現那些煩人的報錯代碼啦!io

相關文章
相關標籤/搜索