Skip to content

Commit

Permalink
Fix http bad response code info
Browse files Browse the repository at this point in the history
  • Loading branch information
evaisse committed Feb 19, 2016
1 parent a1cfbed commit 2a03ce3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Http/Exception/ErrorHttpException.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ abstract class ErrorHttpException extends HttpException
*/
public static function createHttpException(Response $response)
{
$message = \Symfony\Component\HttpFoundation\Response::$statusTexts[$response->getStatusCode()];

/*
* We create a standard Response exception to forward exception response content if necessary
*/
$previous = new ResponseException($response, "", 0);
$previous = new ResponseException($response, "Http Error : " . $response->getStatusCode(), 0);

switch ($response->getStatusCode()) {
case 0:
$e = new InternalServerErrorHttpException("Unknow error code ".$response->getStatusCode(), $previous);
break;
case 400:
$e = new BadRequestHttpException($response->getContent(), $previous, $response->getStatusCode());
break;
Expand Down Expand Up @@ -113,9 +114,10 @@ public static function createHttpException(Response $response)
case 505:
$e = new HttpVersionNotSupportedHttpException($response->getContent(), $previous, $response->getStatusCode());
break;

default:
$e = $response->getStatusCode() >= 500 ? new ServerErrorHttpException($response->getStatusCode(), "", $previous) : new ClientErrorHttpException("", $previous);
$e = $response->getStatusCode() >= 500
? new InternalServerErrorHttpException("Unknow error code ".$response->getStatusCode(), $previous)
: new BadRequestHttpException("Unknow error code ".$response->getStatusCode(), $previous);
break;
}

Expand Down

0 comments on commit 2a03ce3

Please sign in to comment.