Skip to content

Commit

Permalink
Change to a RuntimeError if neither pydantic nor msgspec are installed
Browse files Browse the repository at this point in the history
As a TypeError is picked up by Quart and turned into a BadRequest,
rather than crashing as a programming error.
  • Loading branch information
pgjones committed Jan 1, 2025
1 parent 7e3ee02 commit b20121e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/quart_schema/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def model_load(
elif _use_msgspec(model_class, preference):
return convert(data, model_class, strict=False)
elif not PYDANTIC_INSTALLED and not MSGSPEC_INSTALLED:
raise TypeError(f"Cannot load {model_class} - try installing msgspec or pydantic")
raise RuntimeError(f"Cannot load {model_class} - try installing msgspec or pydantic")
else:
raise TypeError(f"Cannot load {model_class}")
except (TypeError, MsgSpecValidationError, PydanticValidationError, ValueError) as error:
Expand Down

0 comments on commit b20121e

Please sign in to comment.