P
Phlip
Rubies:
rb_eval_string_protect() calls eval(), so at error time $ERROR_POSITION ($@)
gives me a useless number. I want the line number (and preferably the column
number) of the offending part of the evaluated string.
Raw Ruby does that like this:
stwing = """
puts 'a'
puts undeclaredVariable
puts 'c'
"""
begin
eval(stwing, nil, "yo", 0)
rescue
p $@
end
That outputs ["yo:2"]
How can I get the correct error line number, using the equivalent of
eval()'s last two optional parameters, without converting my string to a
Ruby string and then calling "eval" on it?
rb_eval_string_protect() calls eval(), so at error time $ERROR_POSITION ($@)
gives me a useless number. I want the line number (and preferably the column
number) of the offending part of the evaluated string.
Raw Ruby does that like this:
stwing = """
puts 'a'
puts undeclaredVariable
puts 'c'
"""
begin
eval(stwing, nil, "yo", 0)
rescue
p $@
end
That outputs ["yo:2"]
How can I get the correct error line number, using the equivalent of
eval()'s last two optional parameters, without converting my string to a
Ruby string and then calling "eval" on it?