Skip to content

Commit

Permalink
fix: adjust exception message structure
Browse files Browse the repository at this point in the history
  • Loading branch information
erikwrede committed Nov 9, 2024
1 parent 6cfc4c7 commit e354759
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion graphene/types/tests/test_uuid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'}"
)


Expand Down
9 changes: 6 additions & 3 deletions graphene/types/uuid.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def parse_literal(node, _variables=None):

@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

Check warning on line 33 in graphene/types/uuid.py

View check run for this annotation

Codecov / codecov/patch

graphene/types/uuid.py#L33

Added line #L33 was not covered by tests
try:
return _UUID(value)
except (ValueError, AttributeError):
raise GraphQLError(f"UUID cannot represent value: {repr(value)}")

0 comments on commit e354759

Please sign in to comment.