|
@@ -58,23 +58,14 @@ class HttpKernel implements HttpKernelInterface
|
|
|
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
|
|
|
{
|
|
|
try {
|
|
|
- $response = $this->handleRaw($request, $type);
|
|
|
+ return $this->handleRaw($request, $type);
|
|
|
} catch (\Exception $e) {
|
|
|
if (false === $catch) {
|
|
|
throw $e;
|
|
|
}
|
|
|
|
|
|
- // exception
|
|
|
- $event = new Event($this, 'core.exception', array('request_type' => $type, 'request' => $request, 'exception' => $e));
|
|
|
- $response = $this->dispatcher->notifyUntil($event);
|
|
|
- if (!$event->isProcessed()) {
|
|
|
- throw $e;
|
|
|
- }
|
|
|
-
|
|
|
- $response = $this->filterResponse($response, $request, 'A "core.exception" listener returned a non response object.', $type);
|
|
|
+ return $this->handleException($e, $request, $type);
|
|
|
}
|
|
|
-
|
|
|
- return $response;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -156,6 +147,26 @@ class HttpKernel implements HttpKernelInterface
|
|
|
return $response;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Handles and exception by trying to convert it to a Response.
|
|
|
+ *
|
|
|
+ * @param \Exception $e An \Exception instance
|
|
|
+ * @param Request $request A Request instance
|
|
|
+ * @param integer $type The type of the request
|
|
|
+ *
|
|
|
+ * @return Response A Response instance
|
|
|
+ */
|
|
|
+ protected function handleException(\Exception $e, $request, $type)
|
|
|
+ {
|
|
|
+ $event = new Event($this, 'core.exception', array('request_type' => $type, 'request' => $request, 'exception' => $e));
|
|
|
+ $response = $this->dispatcher->notifyUntil($event);
|
|
|
+ if (!$event->isProcessed()) {
|
|
|
+ throw $e;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->filterResponse($response, $request, 'A "core.exception" listener returned a non response object.', $type);
|
|
|
+ }
|
|
|
+
|
|
|
protected function varToString($var)
|
|
|
{
|
|
|
if (is_object($var)) {
|