Kodi Community Forum
WindowXML OnClick() error handling - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: WindowXML OnClick() error handling (/showthread.php?tid=30919)



WindowXML OnClick() error handling - juju0 - 2008-01-28

Hello,
i'm a noob in XBMC python coding and I have a problem with WindowXML OnClick method : I use the following function for catch exceptions :
Code:
def Excepthook(type, value, tb):
    """
        Intercept all exceptions out of try..except statements and
        make the log.txt file with traceback
    """
    log = open(HOME_DIR+"log.txt","w+")
    log.write("Exception report\n\n")
    lines=traceback.format_exception(type, value, tb)
    log.write("---------------------Traceback lines-----------------------\n")
    log.write("".join(lines))
    log.write("-----------------------------------------------------------\n\n")
    log.write("If you think this is a bug, please send me this file. Thank you.")
    log.close()
    msgbox("An exception occured. Look at the log.txt file.", title="Problem!") # it's a shortcut for Ok dialogs
sys.excepthook=Excepthook

But it's don't work at all in OnClick methods Sad