Mercurial > code > home > repos > light9
diff bin/curvecalc @ 296:e99bd20dad85
curvecalc: fully catch and display errors in expr eval
author | David McClosky <dmcc@bigasterisk.com> |
---|---|
date | Sat, 18 Jun 2005 18:09:34 +0000 |
parents | c9dcc57116c2 |
children | 2193eab0650b |
line wrap: on
line diff
--- a/bin/curvecalc Sat Jun 18 17:10:10 2005 +0000 +++ b/bin/curvecalc Sat Jun 18 18:09:34 2005 +0000 @@ -146,17 +146,19 @@ make_attributes_from_args('submaster', 'subexpr') def scaled(self, t): subexpr_eval = self.subexpr.eval(t) - # this stops an error that didn't used to happen. i think when - # the expr is empty, subexpr_eval becomes None, so this zero - # is ok - if subexpr_eval is None: - subexpr_eval = 0 - if isinstance(subexpr_eval, Submaster.Submaster): - # if the expression returns a submaster, just return it - return subexpr_eval - else: - # otherwise, return our submaster multiplied by the value returned - return self.submaster * subexpr_eval + # we prevent any exceptions from escaping, since they cause us to + # stop sending levels + try: + if isinstance(subexpr_eval, Submaster.Submaster): + # if the expression returns a submaster, just return it + return subexpr_eval + else: + # otherwise, return our submaster multiplied by the value + # returned + return self.submaster * subexpr_eval + except Exception, e: + dispatcher.send("expr_error", sender=self.subexpr, exc=str(e)) + return Submaster.Submaster('Error: %s' % str(e), temporary=True) class Subtermview(tk.Frame): def __init__(self,master,st,**kw):