1111
1212namespace FOS \RestBundle \Request ;
1313
14- use FOS \RestBundle \Util \Codes ;
1514use FOS \RestBundle \Controller \Annotations \QueryParam ;
1615use FOS \RestBundle \Controller \Annotations \Param ;
1716use FOS \RestBundle \Controller \Annotations \RequestParam ;
1817use Doctrine \Common \Util \ClassUtils ;
1918use Symfony \Component \HttpFoundation \Request ;
20- use Symfony \Component \HttpKernel \Exception \HttpException ;
19+ use Symfony \Component \HttpKernel \Exception \BadRequestHttpException ;
2120
2221/**
2322 * Helper to validate parameters of the active request.
@@ -113,7 +112,7 @@ public function get($name, $strict = null)
113112
114113 if (null !== $ failMessage ) {
115114 if ($ strict ) {
116- throw new HttpException (Codes:: HTTP_BAD_REQUEST , $ failMessage );
115+ throw new BadRequestHttpException ( $ failMessage );
117116 }
118117
119118 return $ default ;
@@ -133,8 +132,9 @@ public function get($name, $strict = null)
133132 $ paramType = $ config instanceof QueryParam ? 'Query ' : 'Request ' ;
134133 $ problem = empty ($ param ) ? 'empty ' : 'not a scalar ' ;
135134
136- throw new HttpException (Codes::HTTP_BAD_REQUEST ,
137- sprintf ('%s parameter "%s" is %s ' , $ paramType , $ name , $ problem ));
135+ throw new BadRequestHttpException (
136+ sprintf ('%s parameter "%s" is %s ' , $ paramType , $ name , $ problem )
137+ );
138138 }
139139
140140 return $ this ->cleanParamWithRequirements ($ config , $ param , $ strict );
@@ -151,7 +151,7 @@ public function get($name, $strict = null)
151151 * @param string $param param to clean
152152 * @param boolean $strict is strict
153153 *
154- * @throws \RuntimeException
154+ * @throws BadRequestHttpException
155155 * @return string
156156 */
157157 public function cleanParamWithRequirements (Param $ config , $ param , $ strict )
@@ -165,7 +165,9 @@ public function cleanParamWithRequirements(Param $config, $param, $strict)
165165 if ($ strict ) {
166166 $ paramType = $ config instanceof QueryParam ? 'Query ' : 'Request ' ;
167167
168- throw new HttpException (Codes::HTTP_BAD_REQUEST , $ paramType . " parameter value ' $ param', does not match requirements ' {$ config ->requirements }' " );
168+ throw new BadRequestHttpException (
169+ $ paramType . " parameter value ' $ param', does not match requirements ' {$ config ->requirements }' "
170+ );
169171 }
170172
171173 return null === $ default ? '' : $ default ;
0 commit comments