Exception Manager: add/remove handler for exception in application

# Jump directly to Examples

Exception Manager: add/remove handler for exception in application

pymt.exceptions.pymt_exception_manager

PyMT Exception Manager instance

class pymt.exceptions.ExceptionHandler

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_exception(exception)

Handle one exception, default return ExceptionManager.STOP

class pymt.exceptions.ExceptionManager

ExceptionManager manage exceptions handlers.

add_handler(cls)

Add a new exception handler in the stack

handle_exception(inst)

Called when an exception happend in runTouchApp() main loop

remove_handler(cls)

Remove a exception handler from the stack

Examples

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()

Table Of Contents

Previous topic

Event: Event dispatch framework.

Next topic

Geometry: facilities functions for geometry calculations

This Page