sentry-php: Checking for @ in handleError

If PHP expression was prefixed by @ and error occured, error_reporting() will return 0 in registered error handler. This error will not be logged in Sentry cause in handleError there is a checking that error_reporting is not equal to 0.

The same will happen if error_reporting would be set to 0 in a global scope, so checking for this in a handleError and handleFatalError function is imho not a good idea. In my opinion handle error function should looks like this:

       public function handleError($code, $message, $file = '', $line = 0, $context=array())
       {
            $error_types = $this->error_types;
            if ($error_types === null) {
                $error_types = error_reporting();
            }
            if ($error_types & $code) {
                $e = new ErrorException($message, 0, $code, $file, $line);
                $this->handleException($e, true, $context);
            }
            if ($this->call_existing_error_handler) {
                if ($this->old_error_handler !== null) {
                    return call_user_func($this->old_error_handler, $code, $message, $file, $line, $context);
                } else {
                    return false;
                }
            }
       }

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 31 (18 by maintainers)

Commits related to this issue

Most upvoted comments

What about adding the configuration option to control this? If anyone will want to log suppressed errors, will be could.