diff options
Diffstat (limited to 'config/bootstrap/error.php')
-rw-r--r-- | config/bootstrap/error.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/config/bootstrap/error.php b/config/bootstrap/error.php new file mode 100644 index 0000000..dc33bf5 --- /dev/null +++ b/config/bootstrap/error.php @@ -0,0 +1,37 @@ +<?php +/** + * First, import the relevant Lithium core classes. + */ +use \lithium\core\ErrorHandler; +use \lithium\analysis\Logger; +use lithium\action\Response; +use lithium\net\http\Media; + +/** + * Then, set up a basic logging configuration that will write to a file. + */ +Logger::config(array( + 'error' => array('adapter' => 'File') +)); + + +ErrorHandler::apply('lithium\action\Dispatcher::run', array(), function($info, $params) { + $response = new Response(array('request' => $params['request'])); + + $message = "/(^Template not found|^Controller '\w+' not found|^Action '\w+' not found)/"; + $template = (preg_match($message, $info['message'])) ? '404' : '500'; + + Logger::write('error', "{$info['file']} : {$info['line']} : {$info['message']}"); + switch($template){ + case '500': + debug($info);die; + break; + } + Media::render($response, compact('info', 'params'), array( + 'controller' => 'errors', + 'template' => $template, + 'layout' => 'default', + 'request' => $params['request'] + )); + return $response; +});
\ No newline at end of file |