mirror of
https://github.com/graphql-python/graphene.git
synced 2025-07-07 05:43:10 +03:00
fix: adjust exception message structure
This commit is contained in:
parent
6cfc4c70e3
commit
e354759708
|
@ -47,7 +47,7 @@ def test_uuidstring_invalid_argument():
|
||||||
assert len(result.errors) == 1
|
assert len(result.errors) == 1
|
||||||
assert (
|
assert (
|
||||||
result.errors[0].message
|
result.errors[0].message
|
||||||
== "Variable '$uuid' got invalid value {'not': 'a string'}; UUID must be a string"
|
== "Variable '$uuid' got invalid value {'not': 'a string'}; UUID cannot represent value: {'not': 'a string'}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,9 @@ class UUID(Scalar):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def parse_value(value):
|
def parse_value(value):
|
||||||
if not isinstance(value, (str, _UUID)):
|
if isinstance(value, _UUID):
|
||||||
raise GraphQLError("UUID must be a string")
|
return value
|
||||||
return _UUID(value)
|
try:
|
||||||
|
return _UUID(value)
|
||||||
|
except (ValueError, AttributeError):
|
||||||
|
raise GraphQLError(f"UUID cannot represent value: {repr(value)}")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user