Kohana 3 :: Debugging Error Handling

Error/Exception Handling

Kohana provides both an exception handler and an error handler that transforms errors into exceptions using PHP'sErrorException class. Many details of the error and the internal state of the application is displayed by the handler:
  1. Exception class
  2. Error level
  3. Error message
  4. Source of the error, with the error line highlighted
  5. debug backtrace of the execution flow
  6. Included files, loaded extensions, and global variables

Example

Click any of the links to toggle the display of additional information:

ErrorException [ Notice ]: Undefined variable: var_does_not_exist

MODPATH/userguide/views/userguide/examples/error.php [ 4 ]
<span class="line"><span class="number">1</span> <?php
</span><span class="line"><span class="number">2</span>
</span><span class="line"><span class="number">3</span> // Should trigger an ErrorException with an E_NOTICE level
</span><span class="line highlight"><span class="number">4</span> echo $var_does_not_exist;
</span><span class="line"><span class="number">5</span>
</span><span class="line"><span class="number">6</span> ?></span>
  1. MODPATH/userguide/vendor/markdown/markdown.php [ 330 ] » Kohana_Kodoc_Markdown->doIncludeViews(arguments)
  2. {PHP internal call} » Controller_Userguide->action_docs(arguments)
  3. SYSPATH/classes/kohana/request.php [ 1112 ] » ReflectionMethod->invokeArgs(arguments)
  4. APPPATH/bootstrap.php [ 114 ] » Kohana_Request->execute()

Environment

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));

1 comments:

dasdsa said...

dsdasda

Post a Comment