-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
Preconditions
- Magento 2.1.6
- Php 7
- 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:

As the result, user sees that generalized exception:

I suppose that the catch block should rethrow LocalizedException. There are a lot of places inside placeOrder where LocalizedException could be thrown:

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:

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

Any thought?