Example #1
0
    def capture_exception(self, additional_context=None):
        """
        Record occurred exception, check whether the exception recording is
        enabled or not. If it's enabled then record all the details and store
        them in the database, it will notify email as well. The id of exception
        is SHA256 of frame string
        :return: None
        """
        rq = request
        if not self.active:
            return
        try:
            path = request.path
            host = request.host_url
            method = request.method
        except RuntimeError:
            rq = None
            path = ""
            host = ""
            method = ""

        ty, frames, frame_str, traceback_str, rhash, request_data = \
            get_context_detail(rq, self.masking, self.context_builder, additional_context)
        error = self.model.create_or_update_entity(rhash, host, path, method,
                                                   str(request_data),
                                                   get_exception_name(ty),
                                                   traceback_str)
        self._post_process(rq, frame_str, frames, error)
Example #2
0
    def capture_exception(self, request=None, exception=None, additional_context=None):
        """
        Record the exception details and do post processing actions. this method can be used to track any exceptions,
        even those are being excepted using try/except block.
        :param request:  request object
        :param exception: what type of exception has occurred
        :param additional_context: any additional context
        :return:  None
        """
        if request is not None:
            path = request.path
            host = request.META.get('HTTP_HOST', '')
            method = request.method
        else:
            path = ""
            host = ""
            method = ""

        ty, frames, frame_str, traceback_str, rhash, request_data = \
            get_context_detail(request, masking, context_builder,
                               additional_context=additional_context)
        error = model.create_or_update_entity(rhash, host, path, method,
                                              str(request_data),
                                              get_exception_name(ty),
                                              traceback_str)
        ErrorTracker._post_process(request, frame_str, frames, error)