@@ -1659,52 +1659,52 @@ def __getattr__(self, name):
16591659
16601660 fimport = self ._service .schema .function_import (name )
16611661
1662- def function_import_handler (fimport , response ):
1663- """Get function call response from HTTP Response"""
1664-
1662+ def _handle_function_import_response_status (fimport , response ):
1663+ # errors — raise on any non-2xx response
16651664 if 300 <= response .status_code < 400 :
16661665 raise HttpError (f'Function Import { fimport .name } requires Redirection which is not supported' ,
16671666 response )
1668-
16691667 if response .status_code == 401 :
16701668 raise HttpError (f'Not authorized to call Function Import { fimport .name } ' ,
16711669 response )
1672-
16731670 if response .status_code == 403 :
16741671 raise HttpError (f'Missing privileges to call Function Import { fimport .name } ' ,
16751672 response )
1676-
16771673 if response .status_code == 405 :
16781674 raise HttpError (
16791675 f'Despite definition Function Import { fimport .name } does not support HTTP { fimport .http_method } ' ,
16801676 response )
1681-
16821677 if 400 <= response .status_code < 500 :
16831678 raise HttpError (
16841679 f'Function Import { fimport .name } call has failed with status code { response .status_code } ' ,
16851680 response )
1686-
16871681 if response .status_code >= 500 :
16881682 raise HttpError (f'Server has encountered an error while processing Function Import { fimport .name } ' ,
16891683 response )
16901684
1685+ # warnings — unexpected 2xx codes
16911686 if fimport .return_type is None :
16921687 if response .status_code != 204 :
16931688 logging .getLogger (LOGGER_NAME ).warning (
16941689 'The No Return Function Import %s has replied with HTTP Status Code %d instead of 204' ,
16951690 fimport .name , response .status_code )
1691+ elif response .status_code != 200 :
1692+ logging .getLogger (LOGGER_NAME ).warning (
1693+ 'The Function Import %s has replied with HTTP Status Code %d instead of 200' ,
1694+ fimport .name , response .status_code )
1695+
1696+ def function_import_handler (fimport , response ):
1697+ """Get function call response from HTTP Response"""
1698+
1699+ _handle_function_import_response_status (fimport , response )
16961700
1701+ if fimport .return_type is None :
16971702 if response .text :
16981703 logging .getLogger (LOGGER_NAME ).warning (
16991704 'The No Return Function Import %s has returned content:\n %s' , fimport .name , response .text )
17001705
17011706 return None
17021707
1703- if response .status_code != 200 :
1704- logging .getLogger (LOGGER_NAME ).warning (
1705- 'The Function Import %s has replied with HTTP Status Code %d instead of 200' ,
1706- fimport .name , response .status_code )
1707-
17081708 response_data = response .json ()['d' ]
17091709
17101710 # 1. if return type is an entity type or collection, resolve the entity set once
0 commit comments