Documentation

ExceptionEvent extends RequestEvent
in package

FinalYes

Allows to create a response for a thrown exception.

Call setResponse() to set the response that will be returned for the current request. The propagation of this event is stopped as soon as a response is set.

You can also call setThrowable() to replace the thrown exception. This exception will be thrown if no response is set during processing of this event.

Tags
author

Bernhard Schussek bschussek@gmail.com

Table of Contents

Properties

$allowCustomResponseCode  : bool
$kernel  : mixed
$propagationStopped  : bool
$request  : mixed
$requestType  : int|null
$response  : mixed
$throwable  : Throwable

Methods

__construct()  : mixed
allowCustomResponseCode()  : void
Mark the event as allowing a custom response code.
getKernel()  : HttpKernelInterface
Returns the kernel in which this event was thrown.
getRequest()  : Request
Returns the request the kernel is currently processing.
getRequestType()  : int
Returns the request type the kernel is currently processing.
getResponse()  : Response|null
Returns the response object.
getThrowable()  : Throwable
hasResponse()  : bool
Returns whether a response was set.
isAllowingCustomResponseCode()  : bool
Returns true if the event allows a custom response code.
isMainRequest()  : bool
Checks if this is the main request.
isPropagationStopped()  : bool
Is propagation stopped?
setResponse()  : mixed
Sets a response and stops event propagation.
setThrowable()  : void
Replaces the thrown exception.
stopPropagation()  : void
Stops the propagation of the event to further event listeners.

Properties

$allowCustomResponseCode

private bool $allowCustomResponseCode = false

$propagationStopped

private bool $propagationStopped = false

Methods

allowCustomResponseCode()

Mark the event as allowing a custom response code.

public allowCustomResponseCode() : void

getRequestType()

Returns the request type the kernel is currently processing.

public getRequestType() : int
Return values
int

One of HttpKernelInterface::MAIN_REQUEST and HttpKernelInterface::SUB_REQUEST

getThrowable()

public getThrowable() : Throwable
Return values
Throwable

hasResponse()

Returns whether a response was set.

public hasResponse() : bool
Return values
bool

isAllowingCustomResponseCode()

Returns true if the event allows a custom response code.

public isAllowingCustomResponseCode() : bool
Return values
bool

isMainRequest()

Checks if this is the main request.

public isMainRequest() : bool
Return values
bool

isPropagationStopped()

Is propagation stopped?

public isPropagationStopped() : bool
Return values
bool

True if the Event is complete and no further listeners should be called. False to continue calling listeners.

setResponse()

Sets a response and stops event propagation.

public setResponse(Response $response) : mixed
Parameters
$response : Response

setThrowable()

Replaces the thrown exception.

public setThrowable(Throwable $exception) : void

This exception will be thrown if no response is set in the event.

Parameters
$exception : Throwable

stopPropagation()

Stops the propagation of the event to further event listeners.

public stopPropagation() : void

If multiple event listeners are connected to the same event, no further event listener will be triggered once any trigger calls stopPropagation().


        
On this page

Search results