예제 #1
0
    def assemble_email(self, traceback):
        msg = MIMEText(bytes_(self.email_body(traceback)))
        msg.set_type('text/plain')
        msg.set_param('charset', 'UTF-8')

        subject = bytes_('%s: %s' % (traceback.exc_type, traceback.exc_value))

        msg['Subject'] = bytes_(self.error_subject_prefix + subject)
        msg['From'] = bytes_(self.from_address)
        msg['To'] = bytes_(', '.join(self.error_email))

        return msg
예제 #2
0
    def _report_errors(self, environ, start_response):
        context = RequestContext({'environ': dict(environ)})
        for injector in self.context_injectors:
            context.update(injector(environ))
        traceback = get_current_traceback(skip=2, show_hidden_frames=False, context=context)

        try:
            start_response('500 INTERNAL SERVER ERROR', [
                ('Content-Type', 'text/html; charset=utf-8'),
                # Disable Chrome's XSS protection, the debug
                # output can cause false-positives.
                ('X-XSS-Protection', '0'),
                ])
        except Exception:
            # if we end up here there has been output but an error
            # occurred.  in that situation we can do nothing fancy any
            # more, better log something into the error log and fall
            # back gracefully.
            environ['wsgi.errors'].write(
                'Debugging middleware caught exception in streamed '
                'response at a point where response headers were already '
                'sent.\n')
        else:
            yield bytes_('Internal Server Error')

        traceback.log(environ['wsgi.errors'])

        for r in self.reporters:
            try:
                r.report(traceback)
            except Exception:
                error = get_current_traceback(skip=1, show_hidden_frames=False)
                environ['wsgi.errors'].write('\nError while reporting exception with %s\n' % r)
                environ['wsgi.errors'].write(error.plaintext)
예제 #3
0
 def _generate_response(self, environ, start_response):
     try:
         start_response('500 INTERNAL SERVER ERROR', [
             ('Content-Type', 'text/html; charset=utf-8'),
             # Disable Chrome's XSS protection, the debug
             # output can cause false-positives.
             ('X-XSS-Protection', '0'),
             ])
     except Exception:
         # if we end up here there has been output but an error
         # occurred.  in that situation we can do nothing fancy any
         # more, better log something into the error log and fall
         # back gracefully.
         environ['wsgi.errors'].write(
             'Debugging middleware caught exception in streamed '
             'response at a point where response headers were already '
             'sent.\n')
     else:
         yield bytes_('Internal Server Error')
예제 #4
0
 def _generate_response(self, environ, start_response):
     try:
         start_response(
             '500 INTERNAL SERVER ERROR',
             [
                 ('Content-Type', 'text/html; charset=utf-8'),
                 # Disable Chrome's XSS protection, the debug
                 # output can cause false-positives.
                 ('X-XSS-Protection', '0'),
             ])
     except Exception:
         # if we end up here there has been output but an error
         # occurred.  in that situation we can do nothing fancy any
         # more, better log something into the error log and fall
         # back gracefully.
         environ['wsgi.errors'].write(
             'Debugging middleware caught exception in streamed '
             'response at a point where response headers were already '
             'sent.\n')
     else:
         yield bytes_('Internal Server Error')
예제 #5
0
    def assemble_email(self, traceback):
        msg = MIMEMultipart()

        subject = text_(traceback.exception)

        msg['Subject'] = text_(self.error_subject_prefix + subject)
        msg['From'] = text_(self.from_address)
        msg['To'] = text_(', '.join(self.error_email))

        text = MIMEText(bytes_(self.email_body(traceback)), 'plain', 'utf-8')
        text.set_type('text/plain')
        text.set_param('charset', 'UTF-8')
        msg.attach(text)

        request = traceback.context.get('request')
        if self.dump_request and request is not None:
            part = MIMEApplication(request.as_bytes(self.dump_request_size))
            part.add_header('Content-Disposition', 'attachment; filename="request.txt"')
            msg.attach(part)

        return msg
예제 #6
0
    def _report_errors(self, environ, start_response):
        context = RequestContext({'environ': dict(environ)})
        for injector in self.context_injectors:
            context.update(injector(environ))
        traceback = get_current_traceback(skip=2,
                                          show_hidden_frames=False,
                                          context=context)

        try:
            start_response(
                '500 INTERNAL SERVER ERROR',
                [
                    ('Content-Type', 'text/html; charset=utf-8'),
                    # Disable Chrome's XSS protection, the debug
                    # output can cause false-positives.
                    ('X-XSS-Protection', '0'),
                ])
        except Exception:
            # if we end up here there has been output but an error
            # occurred.  in that situation we can do nothing fancy any
            # more, better log something into the error log and fall
            # back gracefully.
            environ['wsgi.errors'].write(
                'Debugging middleware caught exception in streamed '
                'response at a point where response headers were already '
                'sent.\n')
        else:
            yield bytes_('Internal Server Error')

        traceback.log(environ['wsgi.errors'])

        for r in self.reporters:
            try:
                r.report(traceback)
            except Exception:
                error = get_current_traceback(skip=1, show_hidden_frames=False)
                environ['wsgi.errors'].write(
                    '\nError while reporting exception with %s\n' % r)
                environ['wsgi.errors'].write(error.plaintext)
예제 #7
0
    def assemble_email(self, traceback):
        msg = MIMEMultipart()

        subject = text_(traceback.exception)

        msg['Subject'] = text_(self.error_subject_prefix + subject)
        msg['From'] = text_(self.from_address)
        msg['To'] = text_(', '.join(self.error_email))

        text = MIMEText(bytes_(self.email_body(traceback)), 'plain', 'utf-8')
        text.set_type('text/plain')
        text.set_param('charset', 'UTF-8')
        msg.attach(text)

        request = traceback.context.get('request')
        if self.dump_request and request is not None:
            part = MIMEApplication(request.as_bytes(self.dump_request_size))
            part.add_header('Content-Disposition',
                            'attachment; filename="request.txt"')
            msg.attach(part)

        return msg