Как получить код состояния HTTP из исключения, созданного в Laravel?Php

Кемеровские программисты 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

Вернуться в «Php»