Skip to content

Instantly share code, notes, and snippets.

@sbward
Last active December 14, 2015 23:19
Show Gist options
  • Save sbward/5165105 to your computer and use it in GitHub Desktop.
Save sbward/5165105 to your computer and use it in GitHub Desktop.
<?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