Last active
December 14, 2015 23:19
-
-
Save sbward/5165105 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ExceptionAction extends Action | |
{ | |
public function __construct(Exception $exception, $debugMode = false) | |
{ | |
$this->exception = $exception; | |
$this->debugMode = $debugMode; | |
$this->template = new Template(__TEMPLATES__.'/Debug/Exception.phtml'); // or whatever | |
} | |
public function getResponse() | |
{ | |
if ($this->debugMode) | |
{ | |
// Informative page for developer mode | |
$body = $this->template->render($this->exception); | |
$response->setBody($body); | |
} | |
else | |
{ | |
// Generic page for production mode (calls ErrorAction instead) | |
$errorAction = new ErrorAction(500, "Server Error"); | |
$errorAction->setRequest($this->request); | |
$response = $errorAction->getResponse(); | |
} | |
return $response; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment