Skip to content

Commit

Permalink
Merge pull request #100 from RunnerLee/3.1
Browse files Browse the repository at this point in the history
修改异常默认状态码为 500
  • Loading branch information
JanHuang authored Apr 18, 2018
2 parents 1456b5c + b842e7d commit 79edd84
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public function renderException(Exception $e)
$statusCode = ($e instanceof HttpException) ? $e->getStatusCode() : $e->getCode();

if (!array_key_exists($statusCode, Response::$statusTexts)) {
$statusCode = 502;
$statusCode = Response::HTTP_INTERNAL_SERVER_ERROR;
}

return json($response, $statusCode);
Expand Down
2 changes: 1 addition & 1 deletion tests/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function testHandleException()
$this->app->add('response', $response);
$this->app->add('request', new \FastD\Http\ServerRequest('GET', '/'));
$this->app->shutdown(new \FastD\Http\ServerRequest('GET', '/'), $response);
$this->equalsStatus($response, 502);
$this->equalsStatus($response, 500);
$this->assertTrue(file_exists(app()->getPath().'/runtime/logs/error.log'));
}

Expand Down
2 changes: 1 addition & 1 deletion tests/MinimalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function testHandleException()
$exception = new LogicException('handle exception');
$this->app->handleException($exception);
$response = $this->app->renderException($exception);
$this->equalsStatus($response, 502);
$this->equalsStatus($response, 500);
$this->assertFalse(file_exists(app()->getPath().'/runtime/logs/error.log'));
}

Expand Down
2 changes: 1 addition & 1 deletion tests/NoCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function testHandleException()
$this->app->add('response', $response);
$this->app->add('request', new \FastD\Http\ServerRequest('GET', '/'));
$this->app->shutdown(new \FastD\Http\ServerRequest('GET', '/'), $response);
$this->equalsStatus($response, 502);
$this->equalsStatus($response, 500);
$this->assertTrue(file_exists(app()->getPath().'/runtime/logs/error.log'));
}

Expand Down
2 changes: 1 addition & 1 deletion tests/NoLoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function testHandleRequest()
public function testHandleException()
{
$response = $this->app->renderException(new LogicException('handle exception'));
$this->equalsStatus($response, 502);
$this->equalsStatus($response, 500);
$this->assertFalse(file_exists(app()->getPath().'/runtime/logs/error.log'));
}

Expand Down
2 changes: 1 addition & 1 deletion tests/NotDBTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function testHandleException()
$this->app->add('response', $response);
$this->app->add('request', new \FastD\Http\ServerRequest('GET', '/'));
$this->app->shutdown(new \FastD\Http\ServerRequest('GET', '/'), $response);
$this->equalsStatus($response, 502);
$this->equalsStatus($response, 500);
$this->assertTrue(file_exists(app()->getPath().'/runtime/logs/error.log'));
}

Expand Down

0 comments on commit 79edd84

Please sign in to comment.