File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 1313from .private_link import (_get_private_link_validation_error ,
1414 _is_private_link_redirect )
1515
16+ class _CatchAllErrorDeserializer :
17+ """
18+ A catch-all deserializer that sets the entire response body as the error message.
19+ """
20+
21+ def deserialize_error (self , response : requests .Response , content : bytes ) -> dict :
22+ logging .warning ('Unable to parse error with specific deserializers, using catch-all deserializer.' )
23+ return {
24+ 'message' : content .decode ('utf-8' , errors = 'replace' ),
25+ 'status_code' : response .status_code ,
26+ 'url' : response .url
27+ }
28+
1629# A list of _ErrorDeserializers that are tried in order to parse an API error from a response body. Most errors should
1730# be parsable by the _StandardErrorDeserializer, but additional parsers can be added here for specific error formats.
1831# The order of the parsers is not important, as the set of errors that can be parsed by each parser should be disjoint.
2134 _StandardErrorDeserializer (),
2235 _StringErrorDeserializer (),
2336 _HtmlErrorDeserializer (),
37+ _CatchAllErrorDeserializer (),
2438]
2539
2640# A list of _ErrorCustomizers that are applied to the error arguments after they are parsed. Customizers can modify the
You can’t perform that action at this time.
0 commit comments