@@ -1045,7 +1045,9 @@ def handle_error_response( # pylint: disable=too-many-statements, too-many-bran
10451045 retval .extend ([f" { l } " for l in response_read ])
10461046 retval .append (" map_error(status_code=response.status_code, response=response, error_map=error_map)" )
10471047 error_model = ""
1048- if builder .non_default_errors and self .code_model .options ["models-mode" ]:
1048+ if ( # pylint: disable=too-many-nested-blocks
1049+ builder .non_default_errors and self .code_model .options ["models-mode" ]
1050+ ):
10491051 error_model = ", model=error"
10501052 condition = "if"
10511053 retval .append (" error = None" )
@@ -1062,9 +1064,11 @@ def handle_error_response( # pylint: disable=too-many-statements, too-many-bran
10621064 is_operation_file = True , skip_quote = True , serialize_namespace = self .serialize_namespace
10631065 )
10641066 if self .code_model .options ["models-mode" ] == "dpg" :
1065- retval .append (
1066- f" error = _failsafe_deserialize({ type_annotation } ,{ pylint_disable } \n response)"
1067- )
1067+ if xml_serializable (str (e .default_content_type )):
1068+ fn = "_failsafe_deserialize_xml"
1069+ else :
1070+ fn = "_failsafe_deserialize"
1071+ retval .append (f" error = { fn } ({ type_annotation } ,{ pylint_disable } \n response)" )
10681072 else :
10691073 retval .extend (
10701074 [
@@ -1130,9 +1134,14 @@ def handle_error_response( # pylint: disable=too-many-statements, too-many-bran
11301134 if builder .non_default_errors :
11311135 retval .append (" else:" )
11321136 if self .code_model .options ["models-mode" ] == "dpg" :
1137+ default_exception = next (e for e in builder .exceptions if "default" in e .status_codes and e .type )
1138+ if xml_serializable (str (default_exception .default_content_type )):
1139+ fn = "_failsafe_deserialize_xml"
1140+ else :
1141+ fn = "_failsafe_deserialize"
11331142 retval .extend (
11341143 [
1135- f"{ indent } error = _failsafe_deserialize (" ,
1144+ f"{ indent } error = { fn } (" ,
11361145 f"{ indent } { default_error_deserialization } " ,
11371146 f"{ indent } response," ,
11381147 f"{ indent } )" ,
0 commit comments