|
12 | 12 | use Magento\Framework\Exception\CouldNotSaveException;
|
13 | 13 | use Magento\Framework\Exception\LocalizedException;
|
14 | 14 | use Magento\Framework\Exception\StateException;
|
| 15 | +use Magento\Framework\Phrase; |
15 | 16 | use Magento\Quote\Api\Data\PaymentInterface;
|
16 | 17 | use Magento\Quote\Model\Quote\Address\ToOrder as ToOrderConverter;
|
17 | 18 | use Magento\Quote\Model\Quote\Address\ToOrderAddress as ToOrderAddressConverter;
|
@@ -532,19 +533,31 @@ protected function submitQuote(QuoteEntity $quote, $orderData = [])
|
532 | 533 | );
|
533 | 534 | $this->quoteRepository->save($quote);
|
534 | 535 | } catch (\Exception $e) {
|
535 |
| - if (!empty($this->addressesToSync)) { |
536 |
| - foreach ($this->addressesToSync as $addressId) { |
537 |
| - $this->addressRepository->deleteById($addressId); |
| 536 | + try { |
| 537 | + if (!empty($this->addressesToSync)) { |
| 538 | + foreach ($this->addressesToSync as $addressId) { |
| 539 | + $this->addressRepository->deleteById($addressId); |
| 540 | + } |
538 | 541 | }
|
| 542 | + $this->eventManager->dispatch( |
| 543 | + 'sales_model_service_quote_submit_failure', |
| 544 | + [ |
| 545 | + 'order' => $order, |
| 546 | + 'quote' => $quote, |
| 547 | + 'exception' => $e, |
| 548 | + ] |
| 549 | + ); |
| 550 | + } catch (\Exception $consecutiveException) { |
| 551 | + $message = new Phrase( |
| 552 | + "An exception occurred on 'sales_model_service_quote_submit_failure' event: %1\n%2", |
| 553 | + [ |
| 554 | + $consecutiveException->getMessage(), |
| 555 | + $consecutiveException->getTraceAsString() |
| 556 | + ] |
| 557 | + ); |
| 558 | + |
| 559 | + throw new LocalizedException($message, $e); |
539 | 560 | }
|
540 |
| - $this->eventManager->dispatch( |
541 |
| - 'sales_model_service_quote_submit_failure', |
542 |
| - [ |
543 |
| - 'order' => $order, |
544 |
| - 'quote' => $quote, |
545 |
| - 'exception' => $e |
546 |
| - ] |
547 |
| - ); |
548 | 561 | throw $e;
|
549 | 562 | }
|
550 | 563 | return $order;
|
|
0 commit comments