В обработчиках запросов можно создать метод с именем handle_exception
для обработки непредвиденных ситуаций.
Каркас веб-приложения вызовет его автоматически, когда обнаружит проблему
class YourHandler(webapp.RequestHandler):
def handle_exception(self, exception, mode):
# run the default exception handling
webapp.RequestHandler.handle_exception(self,exception, mode)
# note the error in the log
logging.error("Something bad happend: %s" % str(exception))
# tell your users a friendly message
self.response.out.write("Sorry lovely users, something went wrong")