Adding some form of exception handling to front-end requests
This commit is contained in:
parent
5908e86fc0
commit
b146af66b7
|
@ -10,6 +10,7 @@
|
|||
namespace PHPCI;
|
||||
|
||||
use b8;
|
||||
use b8\Exception\HttpException;
|
||||
use b8\Http\Response;
|
||||
use b8\Http\Response\RedirectResponse;
|
||||
use b8\View;
|
||||
|
@ -70,7 +71,15 @@ class Application extends b8\Application
|
|||
*/
|
||||
public function handleRequest()
|
||||
{
|
||||
$this->response = parent::handleRequest();
|
||||
try {
|
||||
$this->response = parent::handleRequest();
|
||||
} catch (\Exception $ex) {
|
||||
$this->config->set('page_title', 'Error');
|
||||
|
||||
$view = new View('exception');
|
||||
$view->exception = $ex;
|
||||
$this->response->setContent($view->render());
|
||||
}
|
||||
|
||||
if (View::exists('layout') && $this->response->hasLayout()) {
|
||||
$view = new View('layout');
|
||||
|
|
9
PHPCI/View/exception.phtml
Normal file
9
PHPCI/View/exception.phtml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<div class="panel panel-danger">
|
||||
<div class="panel-heading">
|
||||
<h2 class="panel-title">Sorry, there was a problem</h2>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<?php print $exception->getMessage(); ?>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in a new issue