Skip to content

LocalizedException is catched and overwritten with a generalized one in placeOrder #9427

@rzinnatullin

Description

@rzinnatullin

Preconditions

  1. Magento 2.1.6
  2. Php 7
  3. Ubuntu 16.04

Description

I'm creating a module that is subscribed to 'checkout_submit_before' event. In the event handler I'm doing some address validations and in case of issues I'm throwing LocalizedException exception.
However, my exception is catched and overwritten with CouldNotSaveException exception:
image
As the result, user sees that generalized exception:
image
I suppose that the catch block should rethrow LocalizedException. There are a lot of places inside placeOrder where LocalizedException could be thrown:
image
Note that 'Please check the shipping address information' wouldn't be displayed to the user.

If I'm doing this wrong, can you please suggest a good way to show validation errors to the user.

Expected result

I did very simple fix to get what I want:
image

After that I'm getting exactly the behaviour I wanted:
image

Any thought?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: CheckoutComponent: PaymentIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is not validGate 1 Failed. Automatic verification of issue format is failedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releasebugfix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions