Skip to content

Commit

Permalink
Fix errors reported by phpstan in Error package
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Aug 19, 2017
1 parent 60b224b commit 913a728
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Error/ExceptionRenderer.php
Expand Up @@ -170,7 +170,7 @@ public function render()
$message = $this->_message($exception, $code);
$url = $this->controller->request->getRequestTarget();

if (method_exists($exception, 'responseHeader')) {
if ($exception instanceof CakeException) {
$this->controller->response->header($exception->responseHeader());
}
$this->controller->response->statusCode($code);
Expand Down
7 changes: 4 additions & 3 deletions src/Error/Middleware/ErrorHandlerMiddleware.php
Expand Up @@ -16,6 +16,7 @@

use Cake\Core\App;
use Cake\Core\Configure;
use Cake\Core\Exception\Exception as CakeException;
use Cake\Core\InstanceConfigTrait;
use Cake\Error\ExceptionRenderer;
use Cake\Log\Log;
Expand Down Expand Up @@ -90,7 +91,7 @@ public function __invoke($request, $response, $next)
{
try {
return $next($request, $response);
} catch (\Exception $e) {
} catch (Exception $e) {
return $this->handleException($e, $request, $response);
}
}
Expand All @@ -111,7 +112,7 @@ public function handleException($exception, $request, $response)
$this->logException($request, $exception);

return $res;
} catch (\Exception $e) {
} catch (Exception $e) {
$this->logException($request, $e);

$body = $response->getBody();
Expand Down Expand Up @@ -193,7 +194,7 @@ protected function getMessage($request, $exception)
);
$debug = Configure::read('debug');

if ($debug && method_exists($exception, 'getAttributes')) {
if ($debug && $exception instanceof CakeException) {
$attributes = $exception->getAttributes();
if ($attributes) {
$message .= "\nException Attributes: " . var_export($exception->getAttributes(), true);
Expand Down

0 comments on commit 913a728

Please sign in to comment.