Skip to content

Error line reporting in backtraces #18

@AlexEscalante

Description

@AlexEscalante

Hello, and such good code you have here!

I have a small problem with some code I am playing with, copied and pasted from your examples, but with an intentional typo:

begin
  s.run(priv, 'puts "here we go"
  x = X.new
  x.foo
  x.bar

  x.xprivileged_operation # FAIL
  ', source: '<user code>')
rescue SecurityError => e  
  puts "privileged_operation failed due security error:\n#{e.to_s}\n"
rescue Exception => e
  puts "backtrace:\n#{e.to_s}\n"
  e.backtrace.each { |l| puts l }
end

Seems to me like the offending line number there is line 6, but it gets reported as 12:

undefined method `xprivileged_operation' for class `X'
...
<user code>:12:in `<module:SandboxBasenamespace96278636>'
<user code>:1:in `<top (required)>'

I see a pattern on my tests: the line counter gets the lines double and inits at 2, not at zero. And then it ignores blank lines and comments lines...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions