Welcome Guest, Not a member yet? Register   Sign In
Halt execution on any error
#1

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.
Reply
#2

(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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB