Use a better method of extracting the line number from ::SyntaxErrors in exec.rb.

This commit is contained in:
Nathan Weizenbaum 2008-04-18 10:06:04 -07:00
parent 639962bcf6
commit 3be12bcc37
1 changed files with 4 additions and 0 deletions

View File

@ -43,6 +43,10 @@ module Haml
protected
def get_line(exception)
# SyntaxErrors have weird line reporting
# when there's trailing whitespace,
# which there is for Haml documents.
return exception.message.scan(/:(\d+)/)[0] if exception.is_a?(::SyntaxError)
exception.backtrace[0].scan(/:(\d+)/)[0]
end