W3cubDocs

/Laravel 8

Handler

class Handler implements ExceptionHandler (View source)

Traits

ReflectsClosures

Properties

protected Container $container The container implementation.
protected array $dontReport A list of the exception types that are not reported.
protected array $reportCallbacks The callbacks that should be used during reporting.
protected array $renderCallbacks The callbacks that should be used during rendering.
protected array $exceptionMap The registered exception mappings.
protected string[] $internalDontReport A list of the internal exception types that should not be reported.
protected string[] $dontFlash A list of the inputs that are never flashed for validation exceptions.

Methods

array closureParameterTypes(Closure $closure)

Get the class names / types of the parameters of the given Closure.

from ReflectsClosures
string firstClosureParameterType(Closure $closure)

Get the class name of the first parameter of the given Closure.

from ReflectsClosures
void __construct(Container $container)

Create a new exception handler instance.

void register()

Register the exception handling callbacks for the application.

ReportableHandler reportable(callable $reportUsing)

Register a reportable callback.

$this renderable(callable $renderUsing)

Register a renderable callback.

$this map(Closure|string $from, Closure|string|null $to = null)

Register a new exception mapping.

$this ignore(string $class)

Indicate that the given exception type should not be reported.

void report(Throwable $e)

Report or log an exception.

bool shouldReport(Throwable $e)

Determine if the exception should be reported.

bool shouldntReport(Throwable $e)

Determine if the exception is in the "do not report" list.

array exceptionContext(Throwable $e)

Get the default exception context variables for logging.

array context()

Get the default context variables for logging.

Response render(Request $request, Throwable $e)

Render an exception into an HTTP response.

Throwable mapException(Throwable $e)

Map the exception using a registered mapper if possible.

Throwable prepareException(Throwable $e)

Prepare exception for rendering.

Response unauthenticated(Request $request, AuthenticationException $exception)

Convert an authentication exception into a response.

Response convertValidationExceptionToResponse(ValidationException $e, Request $request)

Create a response object from the given validation exception.

Response invalid(Request $request, ValidationException $exception)

Convert a validation exception into a response.

JsonResponse invalidJson(Request $request, ValidationException $exception)

Convert a validation exception into a JSON response.

Response prepareResponse(Request $request, Throwable $e)

Prepare a response for the given exception.

Response convertExceptionToResponse(Throwable $e)

Create a Symfony response for the given exception.

string renderExceptionContent(Throwable $e)

Get the response content for the given exception.

string renderExceptionWithWhoops(Throwable $e)

Render an exception to a string using "Whoops".

Handler whoopsHandler()

Get the Whoops handler for the application.

string renderExceptionWithSymfony(Throwable $e, bool $debug)

Render an exception to a string using Symfony.

Response renderHttpException(HttpExceptionInterface $e)

Render the given HttpException.

void registerErrorViewPaths()

Register the error template hint paths.

string getHttpExceptionView(HttpExceptionInterface $e)

Get the view used to render HTTP exceptions.

Response toIlluminateResponse(Response $response, Throwable $e)

Map the given exception into an Illuminate response.

JsonResponse prepareJsonResponse(Request $request, Throwable $e)

Prepare a JSON response for the given exception.

array convertExceptionToArray(Throwable $e)

Convert the given exception to an array.

void renderForConsole(OutputInterface $output, Throwable $e)

Render an exception to the console.

bool isHttpException(Throwable $e)

Determine if the given exception is an HTTP exception.

Details

protected array closureParameterTypes(Closure $closure)

Get the class names / types of the parameters of the given Closure.

Parameters

Closure $closure

Return Value

array

Exceptions

ReflectionException

protected string firstClosureParameterType(Closure $closure)

Get the class name of the first parameter of the given Closure.

Parameters

Closure $closure

Return Value

string

Exceptions

RuntimeException

void __construct(Container $container)

Create a new exception handler instance.

Parameters

Container $container

Return Value

void

void register()

Register the exception handling callbacks for the application.

Return Value

void

ReportableHandler reportable(callable $reportUsing)

Register a reportable callback.

Parameters

callable $reportUsing

Return Value

ReportableHandler

$this renderable(callable $renderUsing)

Register a renderable callback.

Parameters

callable $renderUsing

Return Value

$this

$this map(Closure|string $from, Closure|string|null $to = null)

Register a new exception mapping.

Parameters

Closure|string $from
Closure|string|null $to

Return Value

$this

protected $this ignore(string $class)

Indicate that the given exception type should not be reported.

Parameters

string $class

Return Value

$this

void report(Throwable $e)

Report or log an exception.

Parameters

Throwable $e

Return Value

void

Exceptions

Throwable

bool shouldReport(Throwable $e)

Determine if the exception should be reported.

Parameters

Throwable $e

Return Value

bool

protected bool shouldntReport(Throwable $e)

Determine if the exception is in the "do not report" list.

Parameters

Throwable $e

Return Value

bool

protected array exceptionContext(Throwable $e)

Get the default exception context variables for logging.

Parameters

Throwable $e

Return Value

array

protected array context()

Get the default context variables for logging.

Return Value

array

Response render(Request $request, Throwable $e)

Render an exception into an HTTP response.

Parameters

Request $request
Throwable $e

Return Value

Response

Exceptions

Throwable

protected Throwable mapException(Throwable $e)

Map the exception using a registered mapper if possible.

Parameters

Throwable $e

Return Value

Throwable

protected Throwable prepareException(Throwable $e)

Prepare exception for rendering.

Parameters

Throwable $e

Return Value

Throwable

protected Response unauthenticated(Request $request, AuthenticationException $exception)

Convert an authentication exception into a response.

Parameters

Request $request
AuthenticationException $exception

Return Value

Response

protected Response convertValidationExceptionToResponse(ValidationException $e, Request $request)

Create a response object from the given validation exception.

Parameters

ValidationException $e
Request $request

Return Value

Response

protected Response invalid(Request $request, ValidationException $exception)

Convert a validation exception into a response.

Parameters

Request $request
ValidationException $exception

Return Value

Response

protected JsonResponse invalidJson(Request $request, ValidationException $exception)

Convert a validation exception into a JSON response.

Parameters

Request $request
ValidationException $exception

Return Value

JsonResponse

protected Response prepareResponse(Request $request, Throwable $e)

Prepare a response for the given exception.

Parameters

Request $request
Throwable $e

Return Value

Response

protected Response convertExceptionToResponse(Throwable $e)

Create a Symfony response for the given exception.

Parameters

Throwable $e

Return Value

Response

protected string renderExceptionContent(Throwable $e)

Get the response content for the given exception.

Parameters

Throwable $e

Return Value

string

protected string renderExceptionWithWhoops(Throwable $e)

Render an exception to a string using "Whoops".

Parameters

Throwable $e

Return Value

string

protected Handler whoopsHandler()

Get the Whoops handler for the application.

Return Value

Handler

protected string renderExceptionWithSymfony(Throwable $e, bool $debug)

Render an exception to a string using Symfony.

Parameters

Throwable $e
bool $debug

Return Value

string

protected Response renderHttpException(HttpExceptionInterface $e)

Render the given HttpException.

Parameters

HttpExceptionInterface $e

Return Value

Response

protected void registerErrorViewPaths()

Register the error template hint paths.

Return Value

void

protected string getHttpExceptionView(HttpExceptionInterface $e)

Get the view used to render HTTP exceptions.

Parameters

HttpExceptionInterface $e

Return Value

string

protected Response toIlluminateResponse(Response $response, Throwable $e)

Map the given exception into an Illuminate response.

Parameters

Response $response
Throwable $e

Return Value

Response

protected JsonResponse prepareJsonResponse(Request $request, Throwable $e)

Prepare a JSON response for the given exception.

Parameters

Request $request
Throwable $e

Return Value

JsonResponse

protected array convertExceptionToArray(Throwable $e)

Convert the given exception to an array.

Parameters

Throwable $e

Return Value

array

void renderForConsole(OutputInterface $output, Throwable $e)

Render an exception to the console.

Parameters

OutputInterface $output
Throwable $e

Return Value

void

protected bool isHttpException(Throwable $e)

Determine if the given exception is an HTTP exception.

Parameters

Throwable $e

Return Value

bool

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/8.x/Illuminate/Foundation/Exceptions/Handler.html