コード例 #1
0
    def _is_ignored_error(self, event, hint):
        # type: (Dict[str, Any], Dict[str, Any]) -> bool
        exc_info = hint.get("exc_info")
        if exc_info is None:
            return self._is_ignored_logger(event)

        keylist = []
        except_type = get_type_name(exc_info[0])
        except_module = exc_info[0].__module__ #the original module

        keylist += [except_type, except_module, except_module + '.' + except_type]

        traced_exception = event.get('exception')
        if traced_exception:
            try:
                traced_emit_module = traced_exception['values'][0]['stacktrace']['frames'][-1]['module']
                keylist += [traced_emit_module, traced_emit_module + '.' + except_type]
            except:
                # fixme: may be not a good practise to do like this
                return False # do not ignore

        for e in self.options["ignore_errors"]:
            if isinstance(e, string_types):
                if e in keylist:
                    return True
            else:
                try:
                    if issubclass(exc_info[0], e):
                        return True
                except:
                    return False # do not ignore
        return False
コード例 #2
0
ファイル: client.py プロジェクト: peterdemin/sentry-python
    def _is_ignored_error(self, event, hint=None):
        exc_info = hint.get("exc_info")
        if exc_info is None:
            return False

        type_name = get_type_name(exc_info[0])
        full_name = "%s.%s" % (exc_info[0].__module__, type_name)

        for errcls in self.options["ignore_errors"]:
            # String types are matched against the type name in the
            # exception only
            if isinstance(errcls, string_types):
                if errcls == full_name or errcls == type_name:
                    return True
            else:
                if issubclass(exc_info[0], errcls):
                    return True

        return False
コード例 #3
0
ファイル: client.py プロジェクト: getsentry/sentry-python
    def _is_ignored_error(self, event, hint):
        # type: (Event, Hint) -> bool
        exc_info = hint.get("exc_info")
        if exc_info is None:
            return False

        error = exc_info[0]
        error_type_name = get_type_name(exc_info[0])
        error_full_name = "%s.%s" % (exc_info[0].__module__, error_type_name)

        for ignored_error in self.options["ignore_errors"]:
            # String types are matched against the type name in the
            # exception only
            if isinstance(ignored_error, string_types):
                if ignored_error == error_full_name or ignored_error == error_type_name:
                    return True
            else:
                if issubclass(error, ignored_error):
                    return True

        return False