• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.