From: Chris Hall Date: 2007-09-20T02:44:03+09:00 Subject: exceptions and eval'ing a string Here's my situation I have a setup such as: ----task.rb---- class Task def initialize(name, &action) @name = name @action = action end def run @action.call(self) end end ----task_runner.rb---- require 'task' t = Task.new('task_1') { |t| puts t.name } t.run # => thing what i am now trying to do is put the Task creation code inside a file and eval that as a string ----thing.task---- Task.new('task_1') P |t| puts t.name } ----task_runner.rb---- require 'task' def load_task @t = eval('thing.task') end @t = nil load_task @t.run and this works...however, the difference is that if an exception is thrown as part of the Task's action (when it is run) eval craps out with an exception like (eval):15 and it brings down the entire script, which is a bad thing because i'm running each task in a thread. this doesn't happen obviously when i'm not eval'ing. can someone explain to me what is going on? I'm thinking it's a scoping/context thing, but i'm not really sure. Chris -- Posted via http://www.ruby-forum.com/.