From 5dc1c4f917d0a70b0a49eade7e51e69336e2ee8c Mon Sep 17 00:00:00 2001 From: Pierre-Yves LEBECQ Date: Wed, 17 Jul 2013 10:48:21 +0200 Subject: [PATCH 1/2] [Controller] Any kind of exception are now re-thrown as SoapFault. --- Controller/SoapWebServiceController.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Controller/SoapWebServiceController.php b/Controller/SoapWebServiceController.php index 2576fa5..becd6f5 100644 --- a/Controller/SoapWebServiceController.php +++ b/Controller/SoapWebServiceController.php @@ -123,10 +123,14 @@ class SoapWebServiceController extends ContainerAware // forward to controller try { $response = $this->container->get('http_kernel')->handle($this->soapRequest, HttpKernelInterface::SUB_REQUEST, false); - } catch (\SoapFault $e) { + } catch (\Exception $e) { $this->soapResponse = new Response(null, 500); - throw $e; + if ($this->container->getParameter('kernel.debug')) { + throw $e; + } + + throw new \SoapFault('Receiver', $e->getMessage()); } $this->setResponse($response); From faa1a84c0bcb4cee0c63080bd5d82fdafb8c6a1e Mon Sep 17 00:00:00 2001 From: Pierre-Yves LEBECQ Date: Wed, 17 Jul 2013 11:20:59 +0200 Subject: [PATCH 2/2] [Controller] Prevented instanciation of a new SoapFault if the catched exception is already a SoapFault. --- Controller/SoapWebServiceController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/SoapWebServiceController.php b/Controller/SoapWebServiceController.php index becd6f5..c2d7c1c 100644 --- a/Controller/SoapWebServiceController.php +++ b/Controller/SoapWebServiceController.php @@ -126,7 +126,7 @@ class SoapWebServiceController extends ContainerAware } catch (\Exception $e) { $this->soapResponse = new Response(null, 500); - if ($this->container->getParameter('kernel.debug')) { + if ($e instanceof \SoapFault || $this->container->getParameter('kernel.debug')) { throw $e; }