Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see errors suppressed by '@'?

I joined this crazy company as a Site Administrator. Now I did some changes to my db configurations which have impacted the PHP scripts execution.

Strange part is PHP scripts just die. They don't throw any errors. When I went inside the scripts I realized they have used @ error suppression directive. Now the whole codebase is million of lines spread over thousands of file and don't want to run something like sed to replace '@'.

But '@' has made debugging impossible for me. Its like developers are closing their eyes and find vision dark are saying its night.

Is there a way I can undo error suppression done by '@' and let php log directive handle it. Touching the codebase is not an option. I am looking forward for a way where I can do this by modifying the php configuration or adding few lines in the bootstrap file.

like image 324
codersofthedark Avatar asked Jun 01 '15 19:06

codersofthedark


People also ask

How do I suppress an error in Visual Studio?

Suppress specific warnings for Visual C# or F# Or, select the project node and press Alt+Enter. Choose Build, and go to the Errors and warnings subsection. In the Suppress warnings or Suppress specific warnings box, specify the error codes of the warnings that you want to suppress, separated by semicolons.

What is suppression of error?

Suppression of Last Error By default, runtime checking suppresses the most recent error to prevent repeated reports of the same error.

How do I view errors in R?

You can use traceback() to locate where the last error occurred. Usually it will point you to a call you make in your function. Then I typically put browser() at that point, run the function again and see what is going wrong. The number means how deep we are in the nested functions.

How do I show PHP errors?

The quickest way to display all php errors and warnings is to add these lines to your PHP code file: ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);


2 Answers

If you have Xdebug installed and enabled (in development, you should) then you can set the xdebug.scream configuration option, which disables the @-operator.

Alternatively, the scream PECL extension also disables the @-operator (and that's all it does).

Basically you install the extension then set the scream.enabled ini setting to true/on.

like image 90
Stephen Avatar answered Oct 25 '22 13:10

Stephen


Muted errors are still visible for the handler installed via set_error_handler. So you can just add something like this to your bootstrap file:

set_error_handler(function ($errno, $errstr, $errfile, $errline) {
    echo "$errstr at $errfile($errline)\n";
});

or, better,

set_error_handler(function ($errno, $errstr, $errfile, $errline) {
    throw new ErrorException($errstr, $errno, 1, $errfile, $errline);
});

which also would display the stack.

like image 32
georg Avatar answered Oct 25 '22 13:10

georg