in-eval exception

J

Jacek

Hi
I use evals very often in our system. I start to think about little, on page
tracker so I decided to use PrettyException. I overloaded my class
(MException < PrettyException) to add a ability to read evals, and then
the problem came: The only way I can acces code I use with eval is to
create global variable with value of the code and then put this variable
into the code itself (well better look )

########################################################
$str="
begin
raise
rescue => e
puts MException.new($str,e).print_exception()
end
"

eval $str
#########################################################

Inside Exception I need this code to parse it on the page.
Is ther another better way to access eval param (my code)
from inside MException considering that MException is called
inside eval ?
Sorry for my lang. , Jacek Balcerski
 
R

Robert Klemme

Jacek said:
Hi
I use evals very often in our system. I start to think about little, on page
tracker so I decided to use PrettyException. I overloaded my class
(MException < PrettyException) to add a ability to read evals, and then
the problem came: The only way I can acces code I use with eval is to
create global variable with value of the code and then put this variable
into the code itself (well better look )

########################################################
$str="
begin
raise
rescue => e
puts MException.new($str,e).print_exception()
end
"

eval $str
#########################################################

Inside Exception I need this code to parse it on the page.
Is ther another better way to access eval param (my code)
from inside MException considering that MException is called
inside eval ?
Sorry for my lang. , Jacek Balcerski

Simply catch the exception outside the eval:

def foo(code)
begin
eval code
rescue Exception => e
puts MException.new(code,e).print_exception()
end
end

Does that help?

Kind regards

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

eval 10
Eval, SAFE, and Sandbox 4
deepcopy via eval 6
possibly bulletproof eval() 14
eval(string) scope ? 3
BEGIN, eval and $^S 4
eval alternative 3
EJB Bindings - Class Cast Exception 0

Members online

Forum statistics

Threads
474,166
Messages
2,570,902
Members
47,442
Latest member
KevinLocki

Latest Threads

Top