Skip to content

Commit bfc4da1

Browse files
AnujNehraAnujNehra
authored andcommitted
ACP2E-1986: Rest api V1/carts/mine/estimate-shipping-methods show 500 Error
1 parent 97ae099 commit bfc4da1

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ protected function _createFromArray($className, $data)
328328
$object->{$setterName}($setterValue);
329329
}
330330
} catch (\LogicException $e) {
331-
$this->processInputError([$camelCaseProperty]);
331+
$this->processUnsupportedParameter([$camelCaseProperty]);
332332
}
333333
}
334334

@@ -579,4 +579,29 @@ protected function processInputError($inputError)
579579
}
580580
}
581581
}
582+
583+
/**
584+
* Process unsupported parameter input error
585+
*
586+
* @param array $inputError
587+
* @return void
588+
* @throws InputException
589+
*/
590+
private function processUnsupportedParameter(array $inputError): void
591+
{
592+
if (!empty($inputError)) {
593+
$exception = new InputException();
594+
foreach ($inputError as $errorParamField) {
595+
$exception->addError(
596+
new Phrase(
597+
'"'.$errorParamField.'" is not supported. Correct the field name and try again.',
598+
['fieldName' => $errorParamField]
599+
)
600+
);
601+
}
602+
if ($exception->wasErrorAdded()) {
603+
throw $exception;
604+
}
605+
}
606+
}
582607
}

lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ public function testValidateApiPayload(array $payload, int $exception): void
759759
{
760760
if ($exception) {
761761
$this->expectException(InputException::class);
762-
$this->expectExceptionMessage('"City." is required. Enter and try again.');
762+
$this->expectExceptionMessage('"City." is not supported. Correct the field name and try again.');
763763
}
764764
$result = $this->serviceInputProcessor->process(
765765
ShipmentEstimationInterface::class,

0 commit comments

Comments
 (0)