Symfony2 API
Class

Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent

class GetResponseForExceptionEvent extends GetResponseEvent

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 setException() to replace the thrown exception. This
exception will be thrown if no response is set during processing of this
event.

Methods

Response getResponse()

Returns the response object

from GetResponseEvent
setResponse(Response $response)

Sets a response and stops event propagation

from GetResponseEvent
Boolean hasResponse()

Returns whether a response was set

from GetResponseEvent
__construct(HttpKernelInterface $kernel, Request $request, $requestType, Exception $e)

Exception getException()

Returns the thrown exception

setException(Exception $exception)

Replaces the thrown exception

Details

in GetResponseEvent at line 42
public Response getResponse()

Returns the response object

Return Value

Response

in GetResponseEvent at line 54
public setResponse(Response $response)

Sets a response and stops event propagation

Parameters

Response $response

in GetResponseEvent at line 68
public Boolean hasResponse()

Returns whether a response was set

Return Value

Boolean Whether a response was set

at line 40
public __construct(HttpKernelInterface $kernel, Request $request, $requestType, Exception $e)

Parameters

HttpKernelInterface $kernel
Request $request
$requestType
Exception $e

at line 54
public Exception getException()

Returns the thrown exception

Return Value

Exception The thrown exception

at line 68
public setException(Exception $exception)

Replaces the thrown exception

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

Parameters

Exception $exception The thrown exception