Esempio n. 1
0
def report_error(exception, traceback = None, timeout = get_hoptoad_settings().get('HOPTOAD_TIMEOUT', None), request_data = None):
    """
    Report an exception that is not part of a request/response flow
    
    The request_data object may be a dict with keys for relevant values in the 
    Airbrake XML API. 
    """
    
    from hoptoad.handlers import get_handler
    from hoptoad.api import htv2
    
    payload = htv2.hoptoad_xml(exception.__class__.__name__, unicode(exception), traceback, request_data)
    get_handler().enqueue(payload, timeout)
Esempio n. 2
0
def report_error(exception,
                 traceback=None,
                 timeout=get_hoptoad_settings().get('HOPTOAD_TIMEOUT', None),
                 request_data=None):
    """
    Report an exception that is not part of a request/response flow
    
    The request_data object may be a dict with keys for relevant values in the 
    Airbrake XML API. 
    """

    from hoptoad.handlers import get_handler
    from hoptoad.api import htv2

    exception_message = unicode(exception)
    if not exception_message:
        exception_message = str(exception)
    payload = htv2.hoptoad_xml(exception.__class__.__name__, exception_message,
                               traceback, request_data)
    get_handler().enqueue(payload, timeout)
Esempio n. 3
0
 def _init_middleware(self, hoptoad_settings):
     if 'HOPTOAD_API_KEY' not in hoptoad_settings:
         raise MiddlewareNotUsed
     
     if settings.DEBUG:
         if not hoptoad_settings.get('HOPTOAD_NOTIFY_WHILE_DEBUG', False):
             raise MiddlewareNotUsed
     
     self.timeout = hoptoad_settings.get('HOPTOAD_TIMEOUT', None)
     self.notify_404 = hoptoad_settings.get('HOPTOAD_NOTIFY_404', False)
     self.notify_403 = hoptoad_settings.get('HOPTOAD_NOTIFY_403', False)
     
     ignore_agents = hoptoad_settings.get('HOPTOAD_IGNORE_AGENTS', [])
     self.ignore_agents = map(re.compile, ignore_agents)
     
     self.handler = get_handler()
Esempio n. 4
0
    def _init_middleware(self, hoptoad_settings):
        if "HOPTOAD_API_KEY" not in hoptoad_settings:
            raise MiddlewareNotUsed

        blacklisted_envs = hoptoad_settings.get("HOPTOAD_IGNORE_ENV", [])
        env_name = hoptoad_settings.get("HOPTOAD_ENV_NAME", None)

        if env_name in blacklisted_envs:
            raise MiddlewareNotUsed

        if settings.DEBUG:
            if not hoptoad_settings.get("HOPTOAD_NOTIFY_WHILE_DEBUG", False):
                raise MiddlewareNotUsed

        self.timeout = hoptoad_settings.get("HOPTOAD_TIMEOUT", None)
        self.notify_404 = hoptoad_settings.get("HOPTOAD_NOTIFY_404", False)
        self.notify_403 = hoptoad_settings.get("HOPTOAD_NOTIFY_403", False)

        ignore_agents = hoptoad_settings.get("HOPTOAD_IGNORE_AGENTS", [])
        self.ignore_agents = map(re.compile, ignore_agents)

        self.handler = get_handler()
Esempio n. 5
0
    def _init_middleware(self, hoptoad_settings):
        if 'HOPTOAD_API_KEY' not in hoptoad_settings:
            raise MiddlewareNotUsed

        blacklisted_envs = hoptoad_settings.get("HOPTOAD_IGNORE_ENV", [])
        env_name = hoptoad_settings.get("HOPTOAD_ENV_NAME", None)

        if env_name in blacklisted_envs:
            raise MiddlewareNotUsed

        if settings.DEBUG:
            if not hoptoad_settings.get('HOPTOAD_NOTIFY_WHILE_DEBUG', False):
                raise MiddlewareNotUsed

        self.timeout = hoptoad_settings.get('HOPTOAD_TIMEOUT', None)
        self.notify_404 = hoptoad_settings.get('HOPTOAD_NOTIFY_404', False)
        self.notify_403 = hoptoad_settings.get('HOPTOAD_NOTIFY_403', False)

        ignore_agents = hoptoad_settings.get('HOPTOAD_IGNORE_AGENTS', [])
        self.ignore_agents = map(re.compile, ignore_agents)

        self.handler = get_handler()
Esempio n. 6
0
    def _init_middleware(self, hoptoad_settings):
        if 'HOPTOAD_API_KEY' not in hoptoad_settings:
            raise MiddlewareNotUsed

        if settings.DEBUG \
           and not hoptoad_settings.get('HOPTOAD_NOTIFY_WHILE_DEBUG', False):
            raise MiddlewareNotUsed

        self.debug = hoptoad_settings.get('HOPTOAD_DEBUG', False)
        self.timeout = hoptoad_settings.get('HOPTOAD_TIMEOUT', None)
        self.notify_404 = hoptoad_settings.get('HOPTOAD_NOTIFY_404', False)
        self.notify_403 = hoptoad_settings.get('HOPTOAD_NOTIFY_403', False)

        ignore_agents = hoptoad_settings.get('HOPTOAD_IGNORE_AGENTS', [])
        self.ignore_agents = map(re.compile, ignore_agents)

        ignore_exc = hoptoad_settings.get('HOPTOAD_IGNORE_EXCEPTIONS', ())
        self.ignore_exc_types = filter(lambda e: type(e) == type, ignore_exc)
        self.ignore_exc_names = filter(lambda e: isinstance(e, basestring), ignore_exc)

        ignore_exc_messages = hoptoad_settings.get('HOPTOAD_IGNORE_MESSAGES', ())
        self.ignore_exc_messages = map(re.compile, ignore_exc_messages)

        self.handler = get_handler()