Permalink
Browse files

Raise Solid::SyntaxError exceptions

  • Loading branch information...
1 parent 52eedd5 commit 03c6fabc21b9e3264a163c2cac8353e37a97a5e8 @etiennebarrie etiennebarrie committed Jan 19, 2012
Showing with 10 additions and 2 deletions.
  1. +2 −0 lib/solid.rb
  2. +2 −2 lib/solid/parser.rb
  3. +6 −0 spec/solid/arguments_spec.rb
View
2 lib/solid.rb
@@ -37,4 +37,6 @@ def unproxify(object)
end
+ SyntaxError = Class.new(Liquid::SyntaxError)
+
end
View
4 lib/solid/parser.rb
@@ -90,7 +90,7 @@ def dive_in
def parse_one(argument)
type = argument.shift
handler = "handle_#{type.to_s.sub('@', '')}"
- raise SyntaxError, "unknown Ripper type: #{type.inspect}" unless respond_to?(handler)
+ raise Solid::SyntaxError, "unknown Ripper type: #{type.inspect}" unless respond_to?(handler)
public_send handler, *argument
end
@@ -228,7 +228,7 @@ def handle_regexp_literal(regexp_literal, lineno_column)
# # true
# "true", [1, 33]
def handle_kw(keyword, lineno_column)
- raise 'unknown Ripper sexp' unless KEYWORDS.has_key? keyword
+ raise Solid::SyntaxError, 'unknown Ripper sexp' unless KEYWORDS.has_key? keyword
KEYWORDS[keyword]
end
View
6 spec/solid/arguments_spec.rb
@@ -252,6 +252,12 @@ def parse(string, context={})
parse('42.__send__("`", "echo foo")').should be == [nil]
end
+ it "should raise a Solid::SyntaxError on unknown constructs" do
+ expect {
+ parse('{}[]')
+ }.to raise_error(Solid::SyntaxError)
+ end
+
end
context 'with useless round brackets' do

0 comments on commit 03c6fab

Please sign in to comment.