Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1060335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:18:43+00:00 2026-05-16T18:18:43+00:00

I have created a few helpers to catch any PPH errors and then send

  • 0

I have created a few helpers to catch any PPH errors and then send a curl post which will create a ticket with my bug tracking software.

But I can’t get it to work with Codeigniter. Here is my code:


<? function phpErrorHandler($errno, $errstr, $errfile, $errline, $errcontext){

    //If is a notice do nothing.
    if($errno == E_NOTICE | $errno == E_USER_NOTICE): null; else:

    //Error types
    $errortype = array(
      E_ERROR           => 'Error',
      E_WARNING         => 'Warning',
      E_PARSE           => 'Parsing Error',
      E_NOTICE          => 'Notice',
      E_CORE_ERROR      => 'Core Error',
      E_CORE_WARNING    => 'Core Warning',
      E_COMPILE_ERROR   => 'Compile Error',
      E_COMPILE_WARNING => 'Compile Warning',
      E_USER_ERROR      => 'User Error',
      E_USER_WARNING    => 'User Warning',
      E_USER_NOTICE     => 'User Notice',
      E_STRICT          => "Runtime Notice");

    //Just get the filename for the title.
    $filenameGoBoom = explode('/',print_r( $errfile, true));
    $filename = end($filenameGoBoom);

    //MySQL
    if ($errstr == "(SQL)"):
        $errstr = "SQL Error [$errno] " . SQLMESSAGE . "<br />\n";
        $errstr .= "Query : " . SQLQUERY . "<br />\n";
        $errstr .=  "On line " . SQLERRORLINE . " in file " . SQLERRORFILE . " ";
    endif;

    //Write the report and set out the data
    $prefix = ($errortype[$errno]) ? $errortype[$errno] : "Unknown";
    $title = ($errortype[$errno]) ? $filename ." on line ". print_r( $errline, true) : "Unknown error type: [$errfile:$errline] [$errno] $errstr";
    $error = "\n\n---Data---\n". print_r( $errstr, true).
    "\n\n---File---\n". print_r( $errfile, true). "on line ". print_r( $errline, true)." @".date('Y-m-d H:i:s').
    "\n\n---Context---\n".print_r( $errcontext, true).
    "\n\n". print_r( debug_backtrace(), true);

        //Send! Show the error and stop executing the code
        sendError($prefix, $title , $error);

        echo "Whoops, something went wrong, it could of been something you did, or something we've done or didn't expect. Please try again, this error has been reported to us.".$errline.$errstr;

        die();

    endif;
}

function mysqlErrorHandler(){

    //Setup variables.
    $prefix = 'MySQL';
    $title = 'Error - '.mysql_errno();
    $error = 'MySQL Error '.mysql_errno().':'.mysql_error();

    //Send! 
    sendError($prefix,$title,$description);

    //Kill the script
    die();

}

function fatalErrorHandler(){

    $isError = false;
    if ($error = error_get_last()):
        switch($error['type']){
            case E_ERROR:
            case E_CORE_ERROR:
            case E_COMPILE_ERROR:
            case E_USER_ERROR:
            $isError = true;
            break;
            }
        endif;

    if ($isError):
        $prefix = 'Fatal';
        $title = 'Check this out';
        $error = $error['message'];

        sendError($prefix, $title , $error);

        echo "Whoops, something went wrong, it could of been something you did, or something we've done or didn't expect. Please try again, this error has been reported to us.";

    endif; 
}

set_error_handler('phpErrorHandler');
register_shutdown_function('fatalErrorHandler');
?>

It’s not all polished, but thats the code im using. (few bits to clean up & remove) It’s in a helper file which is being autoloaded by codeigniter.

Any ideas?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T18:18:44+00:00Added an answer on May 16, 2026 at 6:18 pm

    You can do a few things quickly to figure out the problem.

    1. Use the above code in a standalone php script and create an intentional error. If the code works, then try to find codeigniter specific error handling mechanism.

    2. Replace the contents of the phpErrorHandler function with something simple, like printing something in the log and see if the function itself is being executed on error. If yes, then you only need to fix the code for the error handler.

    3. For codeigniter specific error handling, you can override its ‘Exception’ library class by creating My_Exception class in your application/libraries folder. Copy original library function signatures into it and put in your code. It will surely work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a few small flash widgets that stream .mp3 audio from an
I have created a few DTS packages and saved them on the server. where
I have created a small flash CS4 project that has a few custom components
How do I create subdomains in ASP.NET? I have few links on my homepage(Home.aspx)
Have created a c++ implementation of the Hough transform for detecting lines in images.
I have created a template for Visual Studio 2008 and it currently shows up
I have created a custom dialog for Visual Studio Setup Project using the steps
I have created a PHP-script to update a web server that is live inside
I have created a UserControl that has a ListView in it. The ListView is
I have created a C# class file by using a XSD-file as an input.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.