changeset 1188:92ffad96fd8a

more error detail on bad expressions Ignore-this: 684cbe10927c70152bd280e3982028d8
author drewp@bigasterisk.com
date Sun, 15 Jun 2014 18:04:55 +0000
parents 102a456be7db
children f6c2da565760
files bin/effecteval light9/effecteval/effect.py light9/effecteval/effectloop.py
diffstat 3 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/bin/effecteval	Sun Jun 15 17:31:29 2014 +0000
+++ b/bin/effecteval	Sun Jun 15 18:04:55 2014 +0000
@@ -53,6 +53,7 @@
 
 @inlineCallbacks
 def insertEnvelopePoints(curve):
+    # wrong: we might not be adding to the currently-playing song.
     musicStatus = yield getMusicStatus()
     songTime=musicStatus['t']
     songDuration=musicStatus['duration']
--- a/light9/effecteval/effect.py	Sun Jun 15 17:31:29 2014 +0000
+++ b/light9/effecteval/effect.py	Sun Jun 15 18:04:55 2014 +0000
@@ -133,7 +133,11 @@
         for c in self.codes:
             codeNs = ns.copy()
             codeNs.update(c.pyResources)
-            lineOut = eval(c.expr, codeNs)
+            try:
+                lineOut = eval(c.expr, codeNs)
+            except Exception as e:
+                e.expr = c.expr
+                raise e
             ns[c.outName] = lineOut
         if 'out' not in ns:
             log.error("ran code for %s, didn't make an 'out' value", self.uri)
--- a/light9/effecteval/effectloop.py	Sun Jun 15 17:31:29 2014 +0000
+++ b/light9/effecteval/effectloop.py	Sun Jun 15 18:04:55 2014 +0000
@@ -147,6 +147,8 @@
             except Exception as exc:
                 now = time.time()
                 if now > self.lastErrorLog + 5:
+                    if hasattr(exc, 'expr'):
+                        log.error('in expression %r', exc.expr)
                     log.error("effect %s: %s" % (e.uri, exc))
                     self.lastErrorLog = now
         log.debug('eval %s effects, got %s outputs', len(self.currentEffects), len(outputs))