def node_request_handler()

in tts/tts/services/amazonpolly.py [0:0]


    def node_request_handler(self, request, response):
        """
        Process service request. The callback function.

        It never raises. If anything unexpected happens, it will return a Polly.Response with details of the exception.

        :param request: an instance of Polly.Request
        :param response: an instance of Polly.Response
        :return: a Polly.Response
        """
        self.loginfo('Amazon Polly Request: {}'.format(request))

        try:
            result = self._dispatch(request)
            self.loginfo('will return {}'.format(result))
            response.result = result
            return response
        except Exception as e:
            current_dir = os.path.dirname(os.path.abspath(__file__))  # todo: make use of pkg_resources
            exc_type = sys.exc_info()[0]

            # not using `issubclass(exc_type, ConnectionError)` for the condition below because some versions
            # of urllib3 raises exception when doing `from requests.exceptions import ConnectionError`
            error_ogg_filename = 'connerror.ogg' if 'ConnectionError' in exc_type.__name__ else 'error.ogg'

            error_details = {
                'Audio File': os.path.join(current_dir, 'data', error_ogg_filename),
                'Audio Type': 'ogg',
                'Exception': {
                    'Type': str(exc_type),
                    'Module': exc_type.__module__,
                    'Name': exc_type.__name__,
                    'Value': str(e),
                },
                'Traceback': traceback.format_exc()
            }

            error_str = json.dumps(error_details)
            self.logerr(error_str)
            response.result = error_str
            return response