CodeIgniter Forums
Halt execution on any error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Halt execution on any error (/showthread.php?tid=74254)



Halt execution on any error - neuron - 09-03-2019

Hi,

I want to stop execution, whenever error occurs.
Currently, for example, I have a variable undefined error, but script continues running after this line.

Thanks in advance.


RE: Halt execution on any error - dave friend - 09-03-2019

(09-03-2019, 06:15 AM)neuron Wrote: Hi,

I want to stop execution, whenever error occurs.
Currently, for example, I have a variable undefined error, but script continues running after this line.

Thanks in advance.

Convert all errors to exceptions by using

PHP Code:
set_error_handler('customErrorHandler');

function 
customErrorHandler($errno$errstr$errfile$errline, array $errcontext)
{
    
// Handles @ error suppression
    
if (error_reporting === 0)
    {
        return 
false;
    }

    throw new 
Exception($errstr0$errno$errfile$errline);


Unhandled exceptions will stop the script.