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.
@author Bernhard Schussek <bschussek@gmail.com>
@api
Expanded class hierarchy of GetResponseForExceptionEvent
class GetResponseForExceptionEvent extends GetResponseEvent {
/**
* The exception object
* @var \Exception
*/
private $exception;
public function __construct(HttpKernelInterface $kernel, Request $request, $requestType, \Exception $e) {
parent::__construct($kernel, $request, $requestType);
$this
->setException($e);
}
/**
* Returns the thrown exception
*
* @return \Exception The thrown exception
*
* @api
*/
public function getException() {
return $this->exception;
}
/**
* Replaces the thrown exception
*
* This exception will be thrown if no response is set in the event.
*
* @param \Exception $exception The thrown exception
*
* @api
*/
public function setException(\Exception $exception) {
$this->exception = $exception;
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Event:: |
private | property | ||
Event:: |
private | property | ||
Event:: |
private | property | ||
Event:: |
public | function | Returns the EventDispatcher that dispatches this Event | |
Event:: |
public | function | Gets the event's name. | |
Event:: |
public | function | Returns whether further event listeners should be triggered. | |
Event:: |
public | function | Stores the EventDispatcher that dispatches this Event | |
Event:: |
public | function | Sets the event's name property. | |
Event:: |
public | function | Stops the propagation of the event to further event listeners. | |
GetResponseEvent:: |
private | property | The response object | |
GetResponseEvent:: |
public | function | Returns the response object | |
GetResponseEvent:: |
public | function | Returns whether a response was set | |
GetResponseEvent:: |
public | function | Sets a response and stops event propagation | |
GetResponseForExceptionEvent:: |
private | property | The exception object | |
GetResponseForExceptionEvent:: |
public | function | Returns the thrown exception | |
GetResponseForExceptionEvent:: |
public | function | Replaces the thrown exception | |
GetResponseForExceptionEvent:: |
public | function |
Overrides KernelEvent:: |
|
KernelEvent:: |
private | property | The kernel in which this event was thrown | |
KernelEvent:: |
private | property | The request the kernel is currently processing | |
KernelEvent:: |
private | property | The request type the kernel is currently processing. One of HttpKernelInterface::MASTER_REQUEST and HttpKernelInterface::SUB_REQUEST | |
KernelEvent:: |
public | function | Returns the kernel in which this event was thrown | |
KernelEvent:: |
public | function | Returns the request the kernel is currently processing | |
KernelEvent:: |
public | function | Returns the request type the kernel is currently processing |