Browse Source

[Routing] Change the Exception namespacing + base class for every exception + update PHPDoc

alexandresalome 14 years ago
parent
commit
07b7dc0c86

+ 2 - 2
src/Symfony/Component/Routing/Exception/Generator/InvalidParameterException.php

@@ -1,12 +1,12 @@
 <?php
 
-namespace Symfony\Component\Routing\Exception\Generator;
+namespace Symfony\Component\Routing\Exception;
 
 /**
  * Exception thrown when a parameter is not valid
  *
  * @author Alexandre Salomé <alexandre.salome@gmail.com>
  */
-class InvalidParameterException extends \Exception
+class InvalidParameterException extends RoutingException
 {
 }

+ 2 - 2
src/Symfony/Component/Routing/Exception/Generator/MissingMandatoryParametersException.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace Symfony\Component\Routing\Exception\Generator;
+namespace Symfony\Component\Routing\Exception;
 
 /**
  * Exception thrown when a route cannot be generated because of missing
@@ -8,6 +8,6 @@ namespace Symfony\Component\Routing\Exception\Generator;
  *
  * @author Alexandre Salomé <alexandre.salome@gmail.com>
  */
-class MissingMandatoryParametersException extends \Exception
+class MissingMandatoryParametersException extends RoutingException
 {
 }

+ 2 - 2
src/Symfony/Component/Routing/Exception/Generator/NotExistingRouteException.php

@@ -1,12 +1,12 @@
 <?php
 
-namespace Symfony\Component\Routing\Exception\Generator;
+namespace Symfony\Component\Routing\Exception;
 
 /**
  * Exception thrown when a route does not exists
  *
  * @author Alexandre Salomé <alexandre.salome@gmail.com>
  */
-class NotExistingRouteException extends \Exception
+class NotExistingRouteException extends RoutingException
 {
 }

+ 12 - 0
src/Symfony/Component/Routing/Exception/RoutingException.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace Symfony\Component\Routing\Exception;
+
+/**
+ * Base routing exception
+ *
+ * @author Alexandre Salomé <alexandre.salome@gmail.com>
+ */
+class RoutingException extends \Exception
+{
+}

+ 6 - 5
src/Symfony/Component/Routing/Generator/UrlGenerator.php

@@ -14,9 +14,9 @@ namespace Symfony\Component\Routing\Generator;
 use Symfony\Component\Routing\Route;
 use Symfony\Component\Routing\RouteCollection;
 use Symfony\Component\Routing\RequestContext;
-use Symfony\Component\Routing\Exception\Generator\InvalidParameterException;
-use Symfony\Component\Routing\Exception\Generator\NotExistingRouteException;
-use Symfony\Component\Routing\Exception\Generator\MissingMandatoryParametersException;
+use Symfony\Component\Routing\Exception\InvalidParameterException;
+use Symfony\Component\Routing\Exception\NotExistingRouteException;
+use Symfony\Component\Routing\Exception\MissingMandatoryParametersException;
 
 /**
  * UrlGenerator generates URL based on a set of routes.
@@ -72,7 +72,7 @@ class UrlGenerator implements UrlGeneratorInterface
      *
      * @return string The generated URL
      *
-     * @throws \InvalidArgumentException When route doesn't exist
+     * @throws Symfony\Component\Routing\Exception\NotExistingRouteException When route doesn't exist
      */
     public function generate($name, array $parameters = array(), $absolute = false)
     {
@@ -88,7 +88,8 @@ class UrlGenerator implements UrlGeneratorInterface
     }
 
     /**
-     * @throws \InvalidArgumentException When route has some missing mandatory parameters
+     * @throws Symfony\Component\Routing\Exception\MissingMandatoryParametersException When route has some missing mandatory parameters
+     * @throws Symfony\Component\Routing\Exception\InvalidParameterException When a parameter value is not correct
      */
     protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $absolute)
     {

+ 4 - 4
tests/Symfony/Tests/Component/Routing/Generator/UrlGeneratorTest.php

@@ -131,7 +131,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @expectedException Symfony\Component\Routing\Exception\Generator\NotExistingRouteException
+     * @expectedException Symfony\Component\Routing\Exception\NotExistingRouteException
      */
     public function testGenerateWithoutRoutes()
     {
@@ -140,7 +140,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @expectedException Symfony\Component\Routing\Exception\Generator\MissingMandatoryParametersException
+     * @expectedException Symfony\Component\Routing\Exception\MissingMandatoryParametersException
      */
     public function testGenerateForRouteWithoutManditoryParameter()
     {
@@ -149,7 +149,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @expectedException Symfony\Component\Routing\Exception\Generator\InvalidParameterException
+     * @expectedException Symfony\Component\Routing\Exception\InvalidParameterException
      */
     public function testGenerateForRouteWithInvalidOptionalParameter()
     {
@@ -158,7 +158,7 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @expectedException Symfony\Component\Routing\Exception\Generator\InvalidParameterException
+     * @expectedException Symfony\Component\Routing\Exception\InvalidParameterException
      */
     public function testGenerateForRouteWithInvalidManditoryParameter()
     {