国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

webman throw new Exception() 拋出異常后無(wú)法獲取錯(cuò)誤碼

鄒意

問題描述

手動(dòng)拋出異常:throw new \Exception('xxxx',100);

public function render(Request $request, Throwable $exception) : Response
    {
        $code = $exception->getCode(); //這始終是0,無(wú)法獲取/////////////
        if ($request->expectsJson()) {
            $json = ['code' => $code ?: 500, 'message' => $this->debug ? $exception->getMessage() : 'Server internal error'];
            $this->debug && $json['traces'] = (string)$exception;
            return new Response(200, ['Content-Type' => 'application/json'],
                json_encode($json, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
        }
        $error = $this->debug ? nl2br((string)$exception) : 'Server internal error';
        return new Response(500, [], $error);
    }
1813 1 0
1個(gè)回答

walkor 打賞
<?php
namespace app\controller;
use support\Request;

class IndexController
{
    public function index(Request $request)
    {
        throw new \Exception('xxxx',100);
    }
}

截圖

沒問題

  • 暫無(wú)評(píng)論
年代過(guò)于久遠(yuǎn),無(wú)法發(fā)表回答
??