Skip to content

Commit bcd7dc8

Browse files
ENGCOM-4520: Root exception not logged on QuoteManagement::submitQuote #21697
- Merge Pull Request #21697 from david-fuehr/magento2:issue-18752-original-exception-lost - Merged commits: 1. 9480e2a 2. 04f60d5 3. 6b0ebf4 4. 59771c4
2 parents 3592a46 + 59771c4 commit bcd7dc8

File tree

1 file changed

+38
-22
lines changed

1 file changed

+38
-22
lines changed

app/code/Magento/Quote/Model/QuoteManagement.php

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -532,28 +532,7 @@ protected function submitQuote(QuoteEntity $quote, $orderData = [])
532532
);
533533
$this->quoteRepository->save($quote);
534534
} catch (\Exception $e) {
535-
try {
536-
if (!empty($this->addressesToSync)) {
537-
foreach ($this->addressesToSync as $addressId) {
538-
$this->addressRepository->deleteById($addressId);
539-
}
540-
}
541-
$this->eventManager->dispatch(
542-
'sales_model_service_quote_submit_failure',
543-
[
544-
'order' => $order,
545-
'quote' => $quote,
546-
'exception' => $e,
547-
]
548-
);
549-
} catch (\Exception $consecutiveException) {
550-
$message = sprintf(
551-
"An exception occurred on 'sales_model_service_quote_submit_failure' event: %s",
552-
$consecutiveException->getMessage()
553-
);
554-
555-
throw new \Exception($message, 0, $e);
556-
}
535+
$this->rollbackAddresses($quote, $order, $e);
557536
throw $e;
558537
}
559538
return $order;
@@ -620,4 +599,41 @@ protected function _prepareCustomerQuote($quote)
620599
$shipping->setIsDefaultBilling(true);
621600
}
622601
}
602+
603+
/**
604+
* Remove related to order and quote addresses and submit exception to further processing.
605+
*
606+
* @param Quote $quote
607+
* @param \Magento\Sales\Api\Data\OrderInterface $order
608+
* @param \Exception $e
609+
* @throws \Exception
610+
*/
611+
private function rollbackAddresses(
612+
QuoteEntity $quote,
613+
\Magento\Sales\Api\Data\OrderInterface $order,
614+
\Exception $e
615+
): void {
616+
try {
617+
if (!empty($this->addressesToSync)) {
618+
foreach ($this->addressesToSync as $addressId) {
619+
$this->addressRepository->deleteById($addressId);
620+
}
621+
}
622+
$this->eventManager->dispatch(
623+
'sales_model_service_quote_submit_failure',
624+
[
625+
'order' => $order,
626+
'quote' => $quote,
627+
'exception' => $e,
628+
]
629+
);
630+
} catch (\Exception $consecutiveException) {
631+
$message = sprintf(
632+
"An exception occurred on 'sales_model_service_quote_submit_failure' event: %s",
633+
$consecutiveException->getMessage()
634+
);
635+
636+
throw new \Exception($message, 0, $e);
637+
}
638+
}
623639
}

0 commit comments

Comments
 (0)