mirror of
https://github.com/graphql-python/graphene.git
synced 2025-04-23 02:32:02 +03:00
fix: adjust exception message structure
This commit is contained in:
parent
6cfc4c70e3
commit
e354759708
graphene/types
|
@ -47,7 +47,7 @@ def test_uuidstring_invalid_argument():
|
|||
assert len(result.errors) == 1
|
||||
assert (
|
||||
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
|
||||
def parse_value(value):
|
||||
if not isinstance(value, (str, _UUID)):
|
||||
raise GraphQLError("UUID must be a string")
|
||||
return _UUID(value)
|
||||
if isinstance(value, _UUID):
|
||||
return 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