def handle_exception(self, exception, debug_mode):    
        logging.exception("handler exception: " + exception)
        self.response.clear()

        if debug_mode:
            lines = ''.join(traceback.format_exception(*sys.exc_info()))
            self.response.write((cgi.escape(lines, quote=True)) % '<pre>%s</pre>')
        else:
            # If the exception is a HTTPException, use its error code.
            # Otherwise use a generic 500 error code.
            if isinstance(exception, webapp2.HTTPException):
                code = exception.code
            else:
                code = 500
            
            self.response.set_status(code)
            self.response.out.write(jinja_environment.get_template("generic_error.html").render({'code' : 500}))
dataset/ETHPy150Open ibagrak/algae/gae/handlers/common.py/BaseHandler.handle_exception/swapped operands of `%`