bugsnag-php: Reporting unhandled exceptions breaks error page handling

Expected behavior

When uncaught exception is thrown, bugsnag intercepts it without possibility to capture it and show custom error page to the user.

Steps to reproduce

<?php
// some code that emits E_NOTICE
// ...

register_shutdown_function(function () use ($bugsnag) {
        if ($error = error_get_last()) {
            if (in_array($error['type'], [E_ERROR, E_PARSE, E_COMPILE_ERROR, E_CORE_ERROR, E_USER_ERROR])) {
                http_response_code(500);
                exit();
            }
        }
    });

$bugsnag = Bugsnag\Client::make($GLOBALS['config']['bugsnag']['api_key']);
Bugsnag\Handler::register($bugsnag);

throw new \RuntimeException('Triggered error 500');
  1. When bugsnag handler is not registered, response has status code 500 error_get_last() correctly returns E_ERROR (intended behaviour)
  2. When bugsnag handler is registered, error_get_last() does not return E_ERROR from RuntimeException anymore, rather some E_NOTICE from prior code.

Version

bugsnag-php v3.12.1 php-fpm 7.2.2

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 19 (10 by maintainers)

Most upvoted comments

This should now be fixed in v3.23.1