Skip to content

Commit 8932966

Browse files
committed
ACP2E-3399: GraphQL Response for Order placement does not include the exception message
1 parent 27e4c96 commit 8932966

File tree

3 files changed

+10
-48
lines changed

3 files changed

+10
-48
lines changed

app/code/Magento/QuoteGraphQl/Model/Resolver/PlaceOrder.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Magento\GraphQl\Helper\Error\AggregateExceptionMessageFormatter;
1818
use Magento\QuoteGraphQl\Model\Cart\GetCartForCheckout;
1919
use Magento\QuoteGraphQl\Model\Cart\PlaceOrder as PlaceOrderModel;
20+
use Magento\QuoteGraphQl\Model\ErrorMapper;
2021
use Magento\QuoteGraphQl\Model\QuoteException;
2122
use Magento\Sales\Api\OrderRepositoryInterface;
2223
use Magento\SalesGraphQl\Model\Formatter\Order as OrderFormatter;
@@ -32,13 +33,15 @@ class PlaceOrder implements ResolverInterface
3233
* @param OrderRepositoryInterface $orderRepository
3334
* @param OrderFormatter $orderFormatter
3435
* @param AggregateExceptionMessageFormatter $errorMessageFormatter
36+
* @param ErrorMapper $errorMapper
3537
*/
3638
public function __construct(
3739
private readonly GetCartForCheckout $getCartForCheckout,
3840
private readonly PlaceOrderModel $placeOrder,
3941
private readonly OrderRepositoryInterface $orderRepository,
4042
private readonly OrderFormatter $orderFormatter,
41-
private readonly AggregateExceptionMessageFormatter $errorMessageFormatter
43+
private readonly AggregateExceptionMessageFormatter $errorMessageFormatter,
44+
private readonly ErrorMapper $errorMapper
4245
) {
4346
}
4447

@@ -72,7 +75,12 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
7275
$context,
7376
$info
7477
);
75-
throw new QuoteException(__($exception->getMessage()), $exception, $exception->getCode());
78+
$exceptionCode = $exception->getCode();
79+
if (!$exceptionCode) {
80+
$exceptionCode = $this->errorMapper->getErrorMessageId($exception->getMessage());
81+
}
82+
83+
throw new QuoteException(__($exception->getMessage()), $exception, $exceptionCode);
7684
}
7785

7886
return [

app/code/Magento/QuoteGraphQl/Plugin/ExceptionMessageDecorator.php

Lines changed: 0 additions & 43 deletions
This file was deleted.

app/code/Magento/QuoteGraphQl/etc/graphql/di.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,4 @@
9191
</argument>
9292
</arguments>
9393
</type>
94-
<type name="Magento\GraphQl\Helper\Error\AggregateExceptionMessageFormatter">
95-
<plugin name="exception_message_decorator" type="Magento\QuoteGraphQl\Plugin\ExceptionMessageDecorator" sortOrder="1"/>
96-
</type>
9794
</config>

0 commit comments

Comments
 (0)