1717use FOS \RestBundle \Controller \Annotations \RequestParam ;
1818use Doctrine \Common \Util \ClassUtils ;
1919use Symfony \Component \HttpFoundation \Request ;
20+ use Symfony \Component \HttpKernel \Exception \BadRequestHttpException ;
2021use Symfony \Component \HttpKernel \Exception \HttpException ;
2122
2223/**
@@ -113,7 +114,7 @@ public function get($name, $strict = null)
113114
114115 if (null !== $ failMessage ) {
115116 if ($ strict ) {
116- throw new HttpException (Codes:: HTTP_BAD_REQUEST , $ failMessage );
117+ throw new BadRequestHttpException ( $ failMessage );
117118 }
118119
119120 return $ default ;
@@ -133,8 +134,9 @@ public function get($name, $strict = null)
133134 $ paramType = $ config instanceof QueryParam ? 'Query ' : 'Request ' ;
134135 $ problem = empty ($ param ) ? 'empty ' : 'not a scalar ' ;
135136
136- throw new HttpException (Codes::HTTP_BAD_REQUEST ,
137- sprintf ('%s parameter "%s" is %s ' , $ paramType , $ name , $ problem ));
137+ throw new BadRequestHttpException (
138+ sprintf ('%s parameter "%s" is %s ' , $ paramType , $ name , $ problem )
139+ );
138140 }
139141
140142 return $ this ->cleanParamWithRequirements ($ config , $ param , $ strict );
@@ -165,7 +167,7 @@ public function cleanParamWithRequirements(Param $config, $param, $strict)
165167 if ($ strict ) {
166168 $ paramType = $ config instanceof QueryParam ? 'Query ' : 'Request ' ;
167169
168- throw new HttpException (Codes:: HTTP_BAD_REQUEST , $ paramType . " parameter value ' $ param', does not match requirements ' {$ config ->requirements }' " );
170+ throw new BadRequestHttpException ( $ paramType . " parameter value ' $ param', does not match requirements ' {$ config ->requirements }' " );
169171 }
170172
171173 return null === $ default ? '' : $ default ;
0 commit comments