Skip to content

Commit e01e04b

Browse files
committed
ACP2E-4033: Issue mapping translated message to error code when placing order via GraphQL
1 parent ea89e3a commit e01e04b

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

app/code/Magento/GraphQl/Helper/Error/AggregateExceptionMessageFormatter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public function getFormatted(
6060
}
6161

6262
$message = $e->getCode() ? __($e->getMessage()) : $defaultMessage;
63-
return new GraphQlInputException($message, $e, $e->getCode());
63+
64+
return new GraphQlInputException(__("$messagePrefix: %message", ['message' => $message]), $e, $e->getCode());
6465
}
6566
}

app/code/Magento/QuoteGraphQl/Model/ErrorMapper.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class ErrorMapper
4343
'Please check the billing address information' => self::ERROR_UNABLE_TO_PLACE_ORDER_ID,
4444
'Enter a valid payment method and try again' => self::ERROR_UNABLE_TO_PLACE_ORDER_ID,
4545
'Some of the products are out of stock' => self::ERROR_UNABLE_TO_PLACE_ORDER_ID,
46+
'Unable to place order' => self::ERROR_UNABLE_TO_PLACE_ORDER_ID,
4647
];
4748

4849
/**

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,15 @@ public function resolve(Field $field, $context, ResolveInfo $info, ?array $value
7070
} catch (LocalizedException $exception) {
7171
$exception = $this->errorMessageFormatter->getFormatted(
7272
$exception,
73-
__('Unable to place order: A server error stopped your order from being placed. ' .
74-
'Please try to place your order again'),
73+
__('A server error stopped your order from being placed. Please try to place your order again'),
7574
'Unable to place order',
7675
$field,
7776
$context,
7877
$info
7978
);
8079
$exceptionCode = $exception->getCode();
8180
if (!$exceptionCode) {
82-
$exceptionCode = $this->errorMapper->getErrorMessageId($exception->getMessage());
81+
$exceptionCode = $this->errorMapper->getErrorMessageId($exception->getRawMessage());
8382
}
8483

8584
throw new QuoteException(__($exception->getMessage()), $exception, $exceptionCode);

0 commit comments

Comments
 (0)