Skip to content

Commit

Permalink
Rescue ::SyntaxError when checking Ruby code
Browse files Browse the repository at this point in the history
Since Haml::Exec::Haml is inside the top Haml module, "SyntaxError"
refers to "Haml::SyntaxError", not the top level "SyntaxError".

Use "::SyntaxError" to make sure we rescue the right one, and avoid
the need to rescue "Exception".
  • Loading branch information
mattwildig committed Jun 8, 2015
1 parent ca9e1c1 commit 9b8ce72
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/haml/exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,7 @@ def process_result
def validate_ruby(code)
begin
eval("BEGIN {return nil}; #{code}")
# Not sure why, but rescuing "SyntaxError" does not work here.
rescue Exception
rescue ::SyntaxError # Not to be confused with Haml::SyntaxError
$!
end
end
Expand Down

0 comments on commit 9b8ce72

Please sign in to comment.