Changeset - e99bd20dad85
[Not reviewed]
default
0 1 0
David McClosky - 20 years ago 2005-06-18 18:09:34
dmcc@bigasterisk.com
curvecalc: fully catch and display errors in expr eval
1 file changed with 13 insertions and 11 deletions:
0 comments (0 inline, 0 general)
bin/curvecalc
Show inline comments
 
@@ -146,17 +146,19 @@ class Subterm:
 
        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):
0 comments (0 inline, 0 general)