mirror of
https://github.com/retailcrm/graphql-php.git
synced 2025-02-16 20:33:14 +03:00
Catch exceptions in isValidPHPValue and return corresponding error message
This commit is contained in:
parent
7937b15855
commit
faf81ef18a
@ -243,16 +243,26 @@ class Values
|
||||
}
|
||||
|
||||
if ($type instanceof LeafType) {
|
||||
// Scalar/Enum input checks to ensure the type can parse the value to
|
||||
// a non-null value.
|
||||
$parseResult = $type->parseValue($value);
|
||||
if (null === $parseResult) {
|
||||
$v = json_encode($value);
|
||||
try {
|
||||
// Scalar/Enum input checks to ensure the type can parse the value to
|
||||
// a non-null value.
|
||||
$parseResult = $type->parseValue($value);
|
||||
if (null === $parseResult) {
|
||||
$v = json_encode($value);
|
||||
return [
|
||||
"Expected type \"{$type->name}\", found $v."
|
||||
];
|
||||
}
|
||||
return [];
|
||||
} catch (\Exception $e) {
|
||||
return [
|
||||
"Expected type \"{$type->name}\", found $v."
|
||||
$e->getMessage()
|
||||
];
|
||||
} catch (\Throwable $e) {
|
||||
return [
|
||||
$e->getMessage()
|
||||
];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
throw new InvariantViolation('Must be input type');
|
||||
|
Loading…
x
Reference in New Issue
Block a user