Skip to content

Commit e354759

Browse files
committed
fix: adjust exception message structure
1 parent 6cfc4c7 commit e354759

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

graphene/types/tests/test_uuid.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def test_uuidstring_invalid_argument():
4747
assert len(result.errors) == 1
4848
assert (
4949
result.errors[0].message
50-
== "Variable '$uuid' got invalid value {'not': 'a string'}; UUID must be a string"
50+
== "Variable '$uuid' got invalid value {'not': 'a string'}; UUID cannot represent value: {'not': 'a string'}"
5151
)
5252

5353

graphene/types/uuid.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ def parse_literal(node, _variables=None):
2929

3030
@staticmethod
3131
def parse_value(value):
32-
if not isinstance(value, (str, _UUID)):
33-
raise GraphQLError("UUID must be a string")
34-
return _UUID(value)
32+
if isinstance(value, _UUID):
33+
return value
34+
try:
35+
return _UUID(value)
36+
except (ValueError, AttributeError):
37+
raise GraphQLError(f"UUID cannot represent value: {repr(value)}")

0 commit comments

Comments
 (0)