Skip to content

Commit baf20c4

Browse files
committed
BadRequestException: added getHttpCode()
1 parent 21bb8b0 commit baf20c4

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/Application/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public function processException($e)
165165
$this->httpResponse->warnOnBuffer = FALSE;
166166
}
167167
if (!$this->httpResponse->isSent()) {
168-
$this->httpResponse->setCode($e instanceof BadRequestException ? ($e->getCode() ?: 404) : 500);
168+
$this->httpResponse->setCode($e instanceof BadRequestException ? ($e->getHttpCode() ?: 404) : 500);
169169
}
170170

171171
$args = ['exception' => $e, 'request' => end($this->requests) ?: NULL];

src/Application/ErrorPresenter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function run(Application\Request $request)
3636
{
3737
$e = $request->getParameter('exception');
3838
if ($e instanceof Application\BadRequestException) {
39-
$code = $e->getCode();
39+
$code = $e->getHttpCode();
4040
} else {
4141
$code = 500;
4242
if ($this->logger) {

src/Application/exceptions.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ public function __construct($message = '', $httpCode = 0, \Exception $previous =
4747
parent::__construct($message, $httpCode ?: $this->code, $previous);
4848
}
4949

50+
51+
/**
52+
* @return int
53+
*/
54+
public function getHttpCode()
55+
{
56+
return $this->code;
57+
}
58+
5059
}
5160

5261

0 commit comments

Comments
 (0)