Jump to content

<p>Debugging</p>


Nabeel
  • After accessing and API function, you can check for an error by:

    1. Seeing the return value (true or false)
    2. Or checking the DB::errno() function

    If a function returns false, it means it failed. But, to ensure a true failure, check the DB::errno() value:

    • DB::errno() - returns the error code that the database returned
    • DB::error() - returns the error message.

    Combine this use with the standard error templates:

    if(DB::errno() != 0)
    {
    	Template::Set('message', 'An error occured! Message: '.DB::error());
    Template::Show('core_error.tpl');
    return false;
    }
    

    You can also output detailed information from the last database call:

    DB::debug();
    

    That will show detailed output on the screen with the query, any errors, and any results returned in an easy to review format.

    Logging Errors

    Within a controller, you can call:

    $this->log('something');

    And it will be posted to the log, in /core/logs/log.txt. This could be useful for non-invasive debugging, or for AJAX requests. These will only be written to the log when DEBUG_MODE is set to 'true' in the local.config.php file.


User Feedback

Recommended Comments

There are no comments to display.



Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Add a comment...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...