Exception Manager: add/remove handler for exception in application
PyMT Exception Manager instance
Base handler that catch exception in runTouchApp(). You can derivate and use it like this
class E(ExceptionHandler):
def handle_exception(self, inst):
pymt_logger.exception(inst)
return ExceptionManager.PASS
pymt_exception_manager.add_handler(E())
All exceptions will be set to PASS, and loggued to console !
Handle one exception, default return ExceptionManager.STOP
ExceptionManager manage exceptions handlers.
Add a new exception handler in the stack
Called when an exception happend in runTouchApp() main loop
Remove a exception handler from the stack
File exceptions.py
# Simple exemple of exception handler
# Exeption will be catch, and set the return to PASS
# So, app will be not stopped by this.
from pymt import *
class E(ExceptionHandler):
def handle_exception(self, inst):
pymt_logger.exception(inst)
return ExceptionManager.PASS
pymt_exception_manager.add_handler(E())
m = MTWindow()
t = MTButton()
@t.event
def on_press(*largs):
print a
m.add_widget(t)
runTouchApp()