Error/Exception Handling
Kohana provides both an exception handler and an error handler that transforms errors into exceptions using PHP's ErrorException class. Many details of the error and the internal state of the application is displayed by the handler:
- Exception class
- Error level
- Error message
- Source of the error, with the error line highlighted
- A debug backtrace of the execution flow
- Included files, loaded extensions, and global variables
Example
Click any of the links to toggle the display of additional information:
ErrorException [ Notice ]:
MODPATH/userguide/views/userguide/examples/error.php [ 4 ]
1 <?php
2
3 // Should trigger an ErrorException with an E_NOTICE level
4 echo $var_does_not_exist;
5
6 ?> -
MODPATH/userguide/views/userguide/examples/error.php [ 4 ] » Kohana_Core::error_handler()
1 <?php 2 3 // Should trigger an ErrorException with an E_NOTICE level 4 echo $var_does_not_exist; 5 6 ?> -
SYSPATH/classes/kohana/view.php [ 61 ] » include(arguments)
0string(52) "MODPATH/userguide/views/userguide/examples/error.php"56 ob_start(); 57 58 try 59 { 60 // Load the view within the current scope 61 include $kohana_view_filename; 62 } 63 catch (Exception $e) 64 { 65 // Delete the output buffer 66 ob_end_clean(); -
SYSPATH/classes/kohana/view.php [ 343 ] » Kohana_View::capture(arguments)
0string(99) "/home/b/biakaveron/ko3.biakaveron.tmweb.ru/ko3/modules/userguide/views/userguide/examples/error.php"338 { 339 throw new Kohana_View_Exception('You must set the file to use within your view before rendering'); 340 } 341 342 // Combine local and global data and capture the output 343 return View::capture($this->_file, $this->_data); 344 } 345 346 } // End View -
MODPATH/userguide/classes/kohana/kodoc/markdown.php [ 56 ] » Kohana_View->render()
51 { 52 list($search, $view) = $set; 53 54 try 55 { 56 $replace[$search] = View::factory($view)->render(); 57 } 58 catch (Exception $e) 59 { 60 ob_start(); 61 -
MODPATH/userguide/vendor/markdown/markdown.php [ 330 ] » Kohana_Kodoc_Markdown->doIncludeViews(arguments)
0string(1019) "<h1>Error/Exception Handling</h1> <p>Kohana provides both an exception handler and an error handler that transforms errors into …"325 # contorted like /[ ]*\n+/ . 326 $text = preg_replace('/^[ ]+$/m', '', $text); 327 328 # Run document gamut methods. 329 foreach ($this->document_gamut as $method => $priority) { 330 $text = $this->$method($text); 331 } 332 333 $this->teardown(); 334 335 return $text . "\n"; -
MODPATH/userguide/vendor/markdown/markdown.php [ 64 ] » Markdown_Parser->transform(arguments)
0string(852) "# Error/Exception Handling Kohana provides both an exception handler and an error handler that transforms errors into exception …"59 $parser_class = MARKDOWN_PARSER_CLASS; 60 $parser = new $parser_class; 61 } 62 63 # Transform text using parser. 64 return $parser->transform($text); 65 } 66 67 68 ### WordPress Plugin Interface ### 69 -
MODPATH/userguide/classes/controller/userguide.php [ 95 ] » Markdown(arguments)
textstring(852) "# Error/Exception Handling Kohana provides both an exception handler and an error handler that transforms errors into exception …"90 91 // Set the page title 92 $this->template->title = $this->title($page); 93 94 // Parse the page contents into the template 95 $this->template->content = Markdown(file_get_contents($file)); 96 97 // Attach the menu to the template 98 $this->template->menu = Markdown(file_get_contents($this->file('menu'))); 99 100 // Bind module menu items -
{PHP internal call} » Controller_Userguide->action_docs(arguments)
0string(16) "debugging.errors" -
SYSPATH/classes/kohana/request.php [ 1196 ] » ReflectionMethod->invokeArgs(arguments)
0object Controller_Userguide(6)
{ public template => object View(2){ protected _file => string(93) "/home/b/biakaveron/ko3.biakaveron.tmweb.ru/ko3/modules/userguide/views/userguide/template.php" protected _data => array(1) ( "title" => string(14) "Error Handling" ) }protected media => object Route(4){ protected _uri => string(20) "guide/media(/<file>)" protected _regex => array(1) ( "file" => string(2) ".+" ) protected _defaults => array(3) ( "controller" => string(9) "userguide" "action" => string(5) "media" "file" => NULL ) protected _route_regex => string(35) "#^guide/media(?:/(?P<file>.+))?$#uD" }protected api => NULL protected guide => object Route(4){ protected _uri => string(14) "guide(/<page>)" protected _regex => array(1) ( "page" => string(2) ".+" ) protected _defaults => array(2) ( "controller" => string(9) "userguide" "action" => string(4) "docs" ) protected _route_regex => string(29) "#^guide(?:/(?P<page>.+))?$#uD" }public auto_render => bool TRUE public request => object Request(9){ public route => object Route(4)}{ protected _uri => string(14) "guide(/<page>)" protected _regex => array(1) ( "page" => string(2) ".+" ) protected _defaults => array(2) ( "controller" => string(9) "userguide" "action" => string(4) "docs" ) protected _route_regex => string(29) "#^guide(?:/(?P<page>.+))?$#uD" }public status => integer 200 public response => string(0) "" public headers => array(1) ( "Content-Type" => string(24) "text/html; charset=utf-8" ) public directory => string(0) "" public controller => string(9) "userguide" public action => string(4) "docs" public uri => string(22) "guide/debugging.errors" protected _params => array(1) ( "page" => string(16) "debugging.errors" ) }1array(1) ( "page" => string(16) "debugging.errors" )
1191 1192 // Determine the action to use 1193 $action = empty($this->action) ? Route::$default_action : $this->action; 1194 1195 // Execute the main action with the parameters 1196 $class->getMethod('action_'.$action)->invokeArgs($controller, $this->_params); 1197 1198 // Execute the "after action" method 1199 $class->getMethod('after')->invoke($controller); 1200 } 1201 catch (Exception $e) -
APPPATH/bootstrap.php [ 108 ] » Kohana_Request->execute()
103 /** 104 * Execute the main request. A source of the URI can be passed, eg: $_SERVER['PATH_INFO']. 105 * If no source is specified, the URI will be automatically detected. 106 */ 107 echo Request::instance() 108 ->execute() 109 ->send_headers() 110 ->response; 111 } -
DOCROOT/index.php [ 104 ] » require(arguments)
0string(21) "APPPATH/bootstrap.php"99 // Load empty core extension 100 require SYSPATH.'classes/kohana'.EXT; 101 } 102 103 // Bootstrap the application 104 require APPPATH.'bootstrap'.EXT;
Environment
Included files (55)
DOCROOT/index.php |
SYSPATH/base.php |
SYSPATH/classes/kohana/core.php |
SYSPATH/classes/kohana.php |
APPPATH/bootstrap.php |
SYSPATH/classes/kohana/log.php |
SYSPATH/classes/kohana/config.php |
SYSPATH/classes/kohana/log/file.php |
SYSPATH/classes/kohana/log/writer.php |
SYSPATH/classes/kohana/config/file.php |
SYSPATH/classes/kohana/config/reader.php |
MODPATH/codebench/init.php |
SYSPATH/classes/route.php |
SYSPATH/classes/kohana/route.php |
MODPATH/userguide/init.php |
SYSPATH/classes/arr.php |
SYSPATH/classes/kohana/arr.php |
SYSPATH/config/userguide.php |
MODPATH/userguide/config/userguide.php |
MODPATH/pagination/config/userguide.php |
MODPATH/oauth/config/userguide.php |
MODPATH/orm/config/userguide.php |
MODPATH/image/config/userguide.php |
MODPATH/database/config/userguide.php |
MODPATH/codebench/config/userguide.php |
MODPATH/cache/config/userguide.php |
MODPATH/auth/config/userguide.php |
SYSPATH/classes/request.php |
SYSPATH/classes/kohana/request.php |
SYSPATH/classes/profiler.php |
SYSPATH/classes/kohana/profiler.php |
MODPATH/userguide/classes/controller/userguide.php |
SYSPATH/classes/controller/template.php |
SYSPATH/classes/kohana/controller/template.php |
SYSPATH/classes/controller.php |
SYSPATH/classes/kohana/controller.php |
SYSPATH/classes/i18n.php |
SYSPATH/classes/kohana/i18n.php |
SYSPATH/classes/cookie.php |
SYSPATH/classes/kohana/cookie.php |
MODPATH/userguide/vendor/markdown/markdown.php |
MODPATH/userguide/classes/kodoc/markdown.php |
MODPATH/userguide/classes/kohana/kodoc/markdown.php |
SYSPATH/classes/url.php |
SYSPATH/classes/kohana/url.php |
SYSPATH/classes/utf8.php |
SYSPATH/classes/kohana/utf8.php |
SYSPATH/classes/view.php |
SYSPATH/classes/kohana/view.php |
SYSPATH/classes/html.php |
SYSPATH/classes/kohana/html.php |
MODPATH/userguide/views/userguide/examples/error.php |
SYSPATH/classes/date.php |
SYSPATH/classes/kohana/date.php |
SYSPATH/views/kohana/error.php |
Loaded extensions (56)
date |
libxml |
openssl |
pcre |
zlib |
bcmath |
calendar |
ctype |
curl |
dba |
dbase |
dom |
hash |
filter |
ftp |
gd |
gettext |
session |
iconv |
standard |
json |
mbstring |
mcrypt |
mhash |
mssql |
mysql |
SimpleXML |
SPL |
PDO |
pdo_mysql |
pdo_sqlite |
posix |
Reflection |
imap |
mysqli |
soap |
sockets |
SQLite |
exif |
sysvsem |
sysvshm |
tidy |
tokenizer |
wddx |
xml |
xmlreader |
xmlwriter |
xsl |
apache |
eAccelerator |
ffmpeg |
memcache |
zip |
timezonedb |
ionCube Loader |
Zend Optimizer |
$_SERVER
DOCUMENT_ROOT |
string(54) "/home/b/biakaveron/ko3.biakaveron.tmweb.ru/public_html" |
HTTP_ACCEPT |
string(83) "text/html,application/xhtml+xml,text/xml;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" |
HTTP_ACCEPT_CHARSET |
string(30) "ISO-8859-1,utf-8;q=0.7,*;q=0.7" |
HTTP_ACCEPT_ENCODING |
string(4) "gzip" |
HTTP_ACCEPT_LANGUAGE |
string(14) "en-us,en;q=0.5" |
HTTP_CACHE_CONTROL |
string(8) "no-cache" |
HTTP_CONNECTION |
string(5) "close" |
HTTP_HOST |
string(14) "ko3.brotkin.ru" |
HTTP_PRAGMA |
string(8) "no-cache" |
HTTP_USER_AGENT |
string(48) "CCBot/1.0 (+http://www.commoncrawl.org/bot.html)" |
HTTP_X_CC_ID |
string(8) "ccc02-01" |
HTTP_X_FORWARDED_FOR |
string(14) "38.107.179.216" |
HTTP_X_REAL_IP |
string(14) "38.107.179.216" |
PATH |
string(183) "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/i486-pc …" |
REDIRECT_STATUS |
string(3) "200" |
REDIRECT_URL |
string(23) "/guide/debugging.errors" |
REMOTE_ADDR |
string(14) "38.107.179.216" |
REMOTE_PORT |
string(5) "35647" |
SCRIPT_FILENAME |
string(64) "/home/b/biakaveron/ko3.biakaveron.tmweb.ru/public_html/index.php" |
SERVER_ADDR |
string(9) "127.0.0.1" |
SERVER_ADMIN |
string(18) "support@timeweb.ru" |
SERVER_NAME |
string(14) "ko3.brotkin.ru" |
SERVER_PORT |
string(2) "80" |
SERVER_SIGNATURE |
string(0) "" |
SERVER_SOFTWARE |
string(13) "Apache/1.3.41" |
GATEWAY_INTERFACE |
string(7) "CGI/1.1" |
SERVER_PROTOCOL |
string(8) "HTTP/1.0" |
REQUEST_METHOD |
string(3) "GET" |
QUERY_STRING |
string(0) "" |
REQUEST_URI |
string(23) "/guide/debugging.errors" |
SCRIPT_NAME |
string(10) "/index.php" |
PATH_INFO |
string(23) "/guide/debugging.errors" |
PATH_TRANSLATED |
string(77) "/home/b/biakaveron/ko3.biakaveron.tmweb.ru/public_html/guide/debugging.errors" |
PHP_SELF |
string(33) "/index.php/guide/debugging.errors" |
REQUEST_TIME |
integer 1328444295 |
argv |
array(0) |
argc |
integer 0 |
Disabling Error/Exception Handling
If you do not want to use the internal error handling, you can disable it when calling Kohana::init:
Kohana::init(array('errors' => FALSE));