Added the details of the bug and the tag for clarity. <div><br></div><div>Manu<br><br><div class="gmail_quote">On Fri, Oct 22, 2010 at 4:32 AM, Manusheel Gupta <span dir="ltr"><<a href="mailto:manu@seeta.in">manu@seeta.in</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Tim,<div><br></div><div>Thanks for the feedback.<br><br><div class="gmail_quote">On Thu, Oct 14, 2010 at 2:11 AM, Tim McNamara <span dir="ltr"><<a href="mailto:paperless@timmcnamara.co.nz" target="_blank">paperless@timmcnamara.co.nz</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><div>On 14 October 2010 08:50, Mukul Gupta <span dir="ltr"><<a href="mailto:mukul@seeta.in" target="_blank">mukul@seeta.in</a>></span> wrote:<br>

</div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
<div class="gmail_quote">Team,<br>
<br></div><div><div class="gmail_quote">Wish to have your feedback on the 
design aspect of the ticket 2063 (Sugar should bring up an alert when an
 unhandled Python exception occurs) - please find the git diff attached 
below. This is an attempt to display an alert when an unhandled Python 
exception occurs in the journal. Unfortunately, when the exception takes
 place in journalactivity.py , I am neither unable to notice the Journal
 Icon (it disappears), </div><div>
<div class="gmail_quote"><br>
<br>
diff --git a/journalactivity.py b/journalactivity.py<br>
index 44cc018..36a2e2e 100644<br>
--- a/journalactivity.py<br>
+++ b/journalactivity.py<br>
@@ -358,8 +358,20 @@ class JournalActivity(Window):<br>
         self.show_main_view()<br>
         self.search_grab_focus()<br>
 <br>
+    def uncaught_exception_alert(self):<br>
+        alert = ErrorAlert(title="Operation could not be performed", msg="Please check the logviewer activity for details ")<br></div></div></div></blockquote><div><br>We can improve the helpfulness of this message. For example, we can tell people which file to open in the log. I would like to give some recommended steps to help get problems fixed, but I haven't included it here.</div>

</div></blockquote><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><div> Also, if they don't have the log viewer activity, then they may feel helpless:<div>

<br></div></div></div></blockquote><div><br></div><div>Right. Point noted.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote">

<div><div>
<br>def uncaught_exception_alert(self):<br></div>    from glob import glob<br>    from os import system<br><br>    logger = ... # should be easy to find<br>    recentlog = glob(<span>"{0}</span><span></span><span>*".format(</span><span></span>logger.filename))[-1]<br>


    last_log_line = system("tail -n 1 {0}".format(recentlog))<br><br>    alert = ErrorAlert(title=_("Sorry, something went wrong"),<br>        msg = _("Please check the file {0} for details.\nThe last line of that file is:\n{1}").format(<br>


            recentlog,<br>            last_log_line))<br>    ...<br></div><div> <br></div></div></blockquote><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="gmail_quote"><div>I also don't like the function name uncaught_exception_alert. Functions should generally begin with verbs. Perhaps handle_uncaught_exception?<br>
<br></div></div></blockquote><div><br></div><div>+1. Yes, we'll use the nomenclature verb_object.</div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="gmail_quote"><div></div><div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex"><div><div> _journal = None<br>
 <br>
+def _alert_excepthook(exc_type, exc_value, traceback):<br>
+    logging.exception('Unhandled Python exception: %s', repr((exc_type, exc_value, traceback)))<br>
+    _journal.uncaught_exception_alert()  <br>
+<br>
+sys.excepthook = _alert_excepthook<br> </div></div></blockquote><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex"><div><div> </div></div></blockquote>


<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex"><div><div class="gmail_quote">+<br>
 def get_journal():<br>
     global _journal<br>
     if _journal is None:<br>
-- <br>
1.7.0.4</div><div class="gmail_quote"><br></div></div><div class="gmail_quote"><br>
I wish to request you to please review the code and suggest desired changes, if any.<br>
<br>
Moreover, I have two important questions regarding the bug.<br>
<br>
1. To catch all unhandled python exceptions in sugar, where exactly 
should we be looking forward to be the venue for adding the 
functionality?<div><br>
    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.<br>
<br></div>
2. Wish if you could recommend on the GUI feature that could be used for displaying the alert message to the user.<br>
<br>Looking forward to for your valuable suggestions,</div></blockquote></div></div>
<br>_______________________________________________<br>
Sugar-devel mailing list<br>
<a href="mailto:Sugar-devel@lists.sugarlabs.org" target="_blank">Sugar-devel@lists.sugarlabs.org</a><br>
<a href="http://lists.sugarlabs.org/listinfo/sugar-devel" target="_blank">http://lists.sugarlabs.org/listinfo/sugar-devel</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>