From df1dc0d666a6bd5c0f3e5528bde0e51533398916 Mon Sep 17 00:00:00 2001 From: Dan Cryer Date: Tue, 8 Oct 2013 08:23:07 +0100 Subject: [PATCH] Error reporting. See #142 --- PHPCI/Application.php | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/PHPCI/Application.php b/PHPCI/Application.php index bfae830c..9bacd78d 100644 --- a/PHPCI/Application.php +++ b/PHPCI/Application.php @@ -24,17 +24,45 @@ class Application extends b8\Application */ public function handleRequest() { - $this->initRequest(); + try { + $this->initRequest(); - // Validate the user's session unless it is a login/logout action or a web hook: - $sessionAction = ($this->controllerName == 'Session' && in_array($this->action, array('login', 'logout'))); - $externalAction = in_array($this->controllerName, array('Bitbucket', 'Github', 'Gitlab', 'BuildStatus')); - $skipValidation = ($externalAction || $sessionAction); + // Validate the user's session unless it is a login/logout action or a web hook: + $sessionAction = ($this->controllerName == 'Session' && in_array($this->action, array('login', 'logout'))); + $externalAction = in_array($this->controllerName, array('Bitbucket', 'Github', 'Gitlab', 'BuildStatus')); + $skipValidation = ($externalAction || $sessionAction); - if($skipValidation || $this->validateSession()) { - parent::handleRequest(); + if($skipValidation || $this->validateSession()) { + parent::handleRequest(); + } + } catch (\Exception $ex) { + $content = '

There was a problem with this request

Please paste the details below into a new bug report so that we can investigate and fix it.

'; + + ob_start(); + var_dump(array( + 'message' => $ex->getMessage(), + 'file' => $ex->getFile(), + 'line' => $ex->getLine(), + 'trace' => $ex->getTraceAsString() + )); + var_dump(array( + 'PATH_INFO' => $_SERVER['PATH_INFO'], + 'REDIRECT_PATH_INFO' => $_SERVER['REDIRECT_PATH_INFO'], + 'REQUEST_URI' => $_SERVER['REQUEST_URI'], + 'PHP_SELF' => $_SERVER['PHP_SELF'], + 'SCRIPT_NAME' => $_SERVER['SCRIPT_NAME'], + 'DOCUMENT_ROOT' => $_SERVER['DOCUMENT_ROOT'], + 'SCRIPT_FILENAME' => $_SERVER['SCRIPT_FILENAME'], + 'SERVER_SOFTWARE' => $_SERVER['SERVER_SOFTWARE'], + )); + $content .= ob_get_contents(); + ob_end_clean(); + + $this->response->setContent($content); + $this->response->disableLayout(); } + if (View::exists('layout') && $this->response->hasLayout()) { $view = new View('layout'); $view->content = $this->response->getContent();