Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for catching throwables in App/Bootstrap #23350

Closed
DuckThom opened this issue Jun 21, 2019 · 2 comments
Closed

Add support for catching throwables in App/Bootstrap #23350

DuckThom opened this issue Jun 21, 2019 · 2 comments
Labels
Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Progress: done Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@DuckThom
Copy link

Summary (*)

I noticed that the inner try/catch in the run method in lib/internal/App/Bootstrap.php does not catch throwables. I was wondering if there is any downside in adding a catch for a \Throwable.

Examples (*)

If an error is thrown (for example, a TypeError) it currently shows a browser generic 500 error.

Proposed solution

I would suggest adding the following catch block for minimal changes as a quite a lot of other methods, like the catchException method for example, expect an instance of \Exception, and a TypeError isn't of that type.

catch (\Throwable $e) {
    \Magento\Framework\Profiler::stop('magento');
    $this->objectManager->get(LoggerInterface::class)->error($e->getMessage());

    // Convert the Throwable to an exception to make it compatible with catchException
    $ex = new \Exception($e->getMessage(), $e->getCode(), $e);

    if (!$application->catchException($this, $ex)) {
        throw $ex;
    }
}
@m2-assistant
Copy link

m2-assistant bot commented Jun 21, 2019

Hi @DuckThom. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

@DuckThom do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Jun 21, 2019
@DuckThom
Copy link
Author

@sdzhepa sdzhepa added the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label Oct 4, 2019
miszyman pushed a commit to miszyman/magento2 that referenced this issue Oct 23, 2019
miszyman pushed a commit to miszyman/magento2 that referenced this issue Oct 24, 2019
@ghost ghost assigned miszyman Dec 5, 2019
magento-engcom-team added a commit that referenced this issue Jan 8, 2020
…3350 #25250

 - Merge Pull Request #25250 from miszyman/magento2:2.3-develop
 - Merged commits:
   1. ee8373f
   2. 5c054e1
   3. 627ac5a
@sidolov sidolov closed this as completed Sep 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Progress: done Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
Archived in project
Development

No branches or pull requests

5 participants