Sugar should bring up an alert when an unhandled python exception occurs
Sugar should bring up an alert when an unhandled python exception occurs
Background Research
Ideally, all exceptions are caught and this scenario should never happen. However, currently, users are left wondering why a certain operation could not be performed and there is nothing to direct them towards their logs which is full of tracebacks. Therefore, it was required to print a notification alert whenever such a thing happens which stated “The operation requested could not be performed. Please check the logviewer activity for details” However, there was some confusion between whether the ‘unhandled’ exceptions were being talked about as Daniel Drake suspected that they were referring to exceptions that are not handled gracefully and instead fall back to a catch-all handler which does not have the knowledge to act on them because technically the exceptions are not unhandled, if they were unhandled then sugar would crash. Tomeu had expressed his desire to use the (Automated Bug Reporting Tool) -abrt functionality used by python processes for such issues. However, that would require some major changes and integration with the school server. In my frequent conversations with Aleksey at IRC- #ubuntu-sugarteam regarding the issue, Aleksey expressed that the bug was undesirable to him and that he preferred something like a bug report. He also mentioned that any proper fix for the bug would be too invasive. Initial Approach: Since, any exception is always logged. Thus, if we could check whether logging.ERROR has been called, there ,an exception has occured .Therefore, if we introduce a flag which attains True value when an exception occurs, and by checking the value of the flag in a GUI file we can generate an alert/notification. For this purpose, I had tried to get a git diff of the sugar.logger and posted on sugar-devel for feedback. However, this approach had major drawbacks as sugar uses standard python logging and any changes in that would be too invasive and inefficient.
Method
Whenever any uncaught exception is raised, the interpreter calls the sys.excepthook(type,value,traceback). After some discussions at #python, we learnt how this functionality could be used in this scenario and prepared a git diff of the file src/jarabe/journal/journalactivity.py
Implementation Code
The following is the git diff. Please find the explanations as comments -
However, the above code caught the unhandled exceptions for only journal files and displayed an error alert in the journal except for journalactivity.py. I realized that whenever any unhandled exception occurs in the file the ‘Journal’ icon itself disappears and there is no other way to go the Journal.
Feedback
1. To catch all unhandled python exceptions in sugar, where exactly should we be looking forward to be the venue for adding the functionality? - Adding it in journalactivity.py doesn't seem to serve all purposes. It has to be added somewhere which is being used all the time.
2. Which GUI feature should be used to add the alert> Adding an alert in Journal looks fine for only Journal related exceptions.
Contact
Mukul Gupta mukul<at>seeta<do>in