diff --git a/.chronus/changes/python-ignoreAllErrors-2026-1-3-14-24-46.md b/.chronus/changes/python-ignoreAllErrors-2026-1-3-14-24-46.md new file mode 100644 index 00000000000..5c88e18f186 --- /dev/null +++ b/.chronus/changes/python-ignoreAllErrors-2026-1-3-14-24-46.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@typespec/http-client-python" +--- + +Ignore all errors thrown during error deserialization, not just `DeserializationError` \ No newline at end of file diff --git a/packages/http-client-python/generator/pygen/codegen/templates/model_base.py.jinja2 b/packages/http-client-python/generator/pygen/codegen/templates/model_base.py.jinja2 index 650204d2e35..b42f50ef661 100644 --- a/packages/http-client-python/generator/pygen/codegen/templates/model_base.py.jinja2 +++ b/packages/http-client-python/generator/pygen/codegen/templates/model_base.py.jinja2 @@ -1062,7 +1062,7 @@ def _failsafe_deserialize( ) -> typing.Any: try: return _deserialize(deserializer, response.json(), module, rf, format) - except DeserializationError: + except Exception: # pylint: disable=broad-except _LOGGER.warning( "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True @@ -1072,11 +1072,11 @@ def _failsafe_deserialize( def _failsafe_deserialize_xml( deserializer: typing.Any, - response: HttpResponse, + response: HttpResponse, ) -> typing.Any: try: return _deserialize_xml(deserializer, response.text()) - except DeserializationError: + except Exception: # pylint: disable=broad-except _LOGGER.warning( "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True