<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def execute_and_handle_webdriver_exceptions(self, function_to_execute, timeout=None, locator=None, failure_message=None):
 """ Executor for wait functions @type function_to_execute: types.FunctionType @param function_to_execute: wait function specifying the type of wait @type timeout: int @param timeout: the maximum number of seconds the driver will wait before timing out @type locator: webdriverwrapper.support.locator.Locator @param locator: locator used to find element @type failure_message: str @param failure_message: message shown in exception if wait fails @rtype: webdriverwrapper.WebElementWrapper @return: Returns the element found """

        logger = logging.getLogger(__name__)
        try:
            val = function_to_execute()
            for cb in self.action_callbacks:
                cb.__call__(self)
            return val

        except TimeoutException:
            raise WebDriverTimeoutException.WebDriverTimeoutException(self, timeout, locator, failure_message)

        except httplib.BadStatusLine, e:
            logger.error('BadStatusLine error raised on WebDriver action (line: {}, args:{}, message: {})'.format(
                e.line,
                e.args,
                e.message
            ))
            raise
        
        except httplib.CannotSendRequest:
            logger.error('CannotSendRequest error raised on WebDriver action')
            raise

        except UnexpectedAlertPresentException:
            # NOTE: handling alerts in this way expects that WebDriver does not dismiss unexpected alerts. That
            # setting can be changed by modifying the unexpectedAlertBehaviour setting
            msg = '<failed to parse message from alert>'
            try:
                a = self.driver.switch_to_alert()
                msg = a.text
            except Exception, e:
                msg = '<error parsing alert due to {} (note: parsing ' \
                      'alert text expects "unexpectedAlertBehaviour" to be set to "ignore")>'.format(e)
                logger.critical(msg)
            finally:
                logger.error('Unexpected alert raised on a WebDriver action; alert message was: {}'.format(msg))
                raise UnexpectedAlertPresentException('Unexpected alert on page, alert message was: "{}"'.format(msg))