這是業(yè)務代碼。
public function test(): Response {
try {
d(123);
return response('hello webman');
} catch (Exception $e) {
throw new BusinessException($e->getMessage());
}
}
這是自定義的異常處理。
class ApiExceptionHandler extends Handler {
use AbortHandler;
public function render(Request $request, Throwable $exception): Response {
if ($exception instanceof Abort) {
return \response($this->convertToHtml($exception));
}
if ($exception instanceof BusinessException) {
return \response('asdfasdf');
}
return parent::render($request, $exception);
}
}
本意是想在index中打印一下參數(shù)到頁面上調(diào)試。。
但是插件是通過異常拋出的寫法,這樣d(123)被拋到BusinessException去了,而不是Abort。
所以。是不是說開發(fā)環(huán)境調(diào)試的時,要把try{}catch{}注掉。。
生產(chǎn)環(huán)境時,不要用d,就用print_r,在命令行顯示,不影響頁面?
但是這里我想要中斷,調(diào)試時,不執(zhí)行后面的代碼,直接拋出。這個要怎么弄?