Skip to content

Commit 814cf2b

Browse files
author
Alex Taranovskyi
committed
Revert exception
1 parent e113e37 commit 814cf2b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/internal/Magento/Framework/GraphQl/Query/EnumLookup.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77

88
namespace Magento\Framework\GraphQl\Query;
99

10+
use Magento\Framework\Exception\RuntimeException;
1011
use Magento\Framework\GraphQl\Config\Element\Enum;
1112
use Magento\Framework\GraphQl\ConfigInterface;
1213
use Magento\Framework\GraphQl\Schema\Type\Enum\DataMapperInterface;
14+
use Magento\Framework\Phrase;
1315

1416
/**
1517
* Processor that looks up definition data of an enum to lookup and convert data as it's specified in the schema.
@@ -27,8 +29,6 @@ class EnumLookup
2729
private $enumDataMapper;
2830

2931
/**
30-
* EnumLookup constructor.
31-
*
3232
* @param ConfigInterface $typeConfig
3333
* @param DataMapperInterface $enumDataMapper
3434
*/
@@ -44,11 +44,19 @@ public function __construct(ConfigInterface $typeConfig, DataMapperInterface $en
4444
* @param string $enumName
4545
* @param string $fieldValue
4646
* @return string
47+
* @throws RuntimeException
4748
*/
4849
public function getEnumValueFromField(string $enumName, string $fieldValue) : string
4950
{
5051
/** @var Enum $enumObject */
5152
$enumObject = $this->typeConfig->getConfigElement($enumName);
53+
54+
if (!($enumObject instanceof Enum)) {
55+
throw new RuntimeException(
56+
new Phrase('Enum type "%1" not defined', [$enumName])
57+
);
58+
}
59+
5260
$mappedValues = $this->enumDataMapper->getMappedEnums($enumName);
5361

5462
foreach ($enumObject->getValues() as $enumItem) {

0 commit comments

Comments
 (0)