Как получить код состояния HTTP из исключения, созданного в Laravel? ⇐ Php
-
Гость
Как получить код состояния HTTP из исключения, созданного в Laravel?
I am currently integrating some logic in App/Exceptions/Handler.php. I would like to be able to access the HTTP Status Code on the $exception variable:
public function report(Throwable $exception) { dd($exception->statusCode); parent::report($exception); } However I get the following error:
ErrorException Undefined property: ErrorException::$statusCode
When I dd($exception) I get the following:
Symfony\Component\HttpKernel\Exception\NotFoundHttpException {#1214 ▼ -statusCode: 404 -headers: [] #message: "" #code: 0 #file: "C:\Users\CEX\Documents\GitHub\unified\vendor\laravel\framework\src\Illuminate\Routing\AbstractRouteCollection.php" #line: 43 trace: {▶} } How do I access the statusCode?
Источник: https://stackoverflow.com/questions/632 ... in-laravel
I am currently integrating some logic in App/Exceptions/Handler.php. I would like to be able to access the HTTP Status Code on the $exception variable:
public function report(Throwable $exception) { dd($exception->statusCode); parent::report($exception); } However I get the following error:
ErrorException Undefined property: ErrorException::$statusCode
When I dd($exception) I get the following:
Symfony\Component\HttpKernel\Exception\NotFoundHttpException {#1214 ▼ -statusCode: 404 -headers: [] #message: "" #code: 0 #file: "C:\Users\CEX\Documents\GitHub\unified\vendor\laravel\framework\src\Illuminate\Routing\AbstractRouteCollection.php" #line: 43 trace: {▶} } How do I access the statusCode?
Источник: https://stackoverflow.com/questions/632 ... in-laravel
Мобильная версия