def write_error(self, status_code, **kwargs):
     try:
         message = '\n'.join(traceback.format_exception(*kwargs['exc_info']))
     except KeyError:
         message = str(status_code)
     email_sender.async_send(title="The Exception Raised", message=message)
     self.render('404.html', page_title="404")
Example #2
0
    def wrapper(cls, *args, **kwargs):
        try:
            connection =\
                torndb.Connection(
                    ":".join(
                        [
                            options.database_address,
                            options.database_port,
                        ]
                    ),
                    cls.db,
                    options.database_user,
                    options.database_password,
                )
            return function(cls, connection, *args, **kwargs)
        except Exception, e:
            # Log error
            logging.error(
                ('Mysql Connection Error: '
                 'Occured when class {0} try to build connection').format(
                     cls.__name__))

            # Send alert email
            message = str(e)
            email_sender.async_send(title="The Exception Raised",
                                    message=message)

            return None if 'query' not in function.__name__ else []
    def wrapper(cls, *args, **kwargs):
        try:
            connection =\
                torndb.Connection(
                    ":".join(
                        [
                            options.database_address,
                            options.database_port,
                        ]
                    ),
                    cls.db,
                    options.database_user,
                    options.database_password,
                )
            return function(cls, connection, *args, **kwargs)
        except Exception, e:
            # Log error
            logging.error(
                (
                    'Mysql Connection Error: '
                    'Occured when class {0} try to build connection'
                ).format(
                    cls.__name__
                )
            )

            # Send alert email
            message = str(e)
            email_sender.async_send(
                title="The Exception Raised",
                message=message
            )

            return None if 'query' not in function.__name__ else []
 def write_error(self, status_code, **kwargs):
     # 403 status means the connection is not authenticated:
     if status_code == 403:
         self.redirect(options.login_url)
     try:
         message = '\n'.join(traceback.format_exception(*kwargs['exc_info']))
     except KeyError:
         message = str(status_code)
     logging.error(message)
     email_sender.async_send(title='The Exception Raised', message=message)
     self.render('404.html', page_title="404")
Example #5
0
 def write_error(self, status_code, **kwargs):
     # 403 status means the connection is not authenticated:
     if status_code == 403:
         self.redirect(options.login_url)
     try:
         message = '\n'.join(
             traceback.format_exception(*kwargs['exc_info']))
     except KeyError:
         message = str(status_code)
     logging.error(message)
     email_sender.async_send(title='The Exception Raised', message=message)
     self.render('404.html', page_title="404")