From: matt@... (matt neuburg) Date: 2009-02-25T04:04:24+09:00 Subject: Re: better error reporting from eval? Tim Pease wrote: > On Feb 24, 2009, at 9:24 AM, matt neuburg wrote: > > > This might seem silly, but it is only a reduced version of a real > > issue. > > Consider the following: > > > > class Thing > > def ev(what) > > eval(what) > > end > > def bar() > > 1 + 1 > > nil + 2 # causing an exception in bar() > > end > > def foo > > bar() > > end > > end > > > > Thing.new.ev("foo()") > > > > def ev(what) > eval(what, binding, __FILE__, __LINE__) > end > > You can pass along the filename and the line number that you want > displayed when eval reports errors. The "binding" is simply the > binding of your current Thing instance. Amazing - just adding the word "binding" (in the actual issue I'm having) in the eval call does indeed solve the whole problem. Thx! m. -- matt neuburg, phd = matt@tidbits.com, http://www.tidbits.com/matt/ Leopard - http://www.takecontrolbooks.com/leopard-customizing.html AppleScript - http://www.amazon.com/gp/product/0596102119 Read TidBITS! It's free and smart. http://www.tidbits.com