Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Raise Solid::SyntaxError exceptions

  • Loading branch information...
commit 03c6fabc21b9e3264a163c2cac8353e37a97a5e8 1 parent 52eedd5
Étienne Barrié etiennebarrie authored
2  lib/solid.rb
@@ -37,4 +37,6 @@ def unproxify(object)
37 37
38 38 end
39 39
  40 + SyntaxError = Class.new(Liquid::SyntaxError)
  41 +
40 42 end
4 lib/solid/parser.rb
@@ -90,7 +90,7 @@ def dive_in
90 90 def parse_one(argument)
91 91 type = argument.shift
92 92 handler = "handle_#{type.to_s.sub('@', '')}"
93   - raise SyntaxError, "unknown Ripper type: #{type.inspect}" unless respond_to?(handler)
  93 + raise Solid::SyntaxError, "unknown Ripper type: #{type.inspect}" unless respond_to?(handler)
94 94 public_send handler, *argument
95 95 end
96 96
@@ -228,7 +228,7 @@ def handle_regexp_literal(regexp_literal, lineno_column)
228 228 # # true
229 229 # "true", [1, 33]
230 230 def handle_kw(keyword, lineno_column)
231   - raise 'unknown Ripper sexp' unless KEYWORDS.has_key? keyword
  231 + raise Solid::SyntaxError, 'unknown Ripper sexp' unless KEYWORDS.has_key? keyword
232 232 KEYWORDS[keyword]
233 233 end
234 234
6 spec/solid/arguments_spec.rb
@@ -252,6 +252,12 @@ def parse(string, context={})
252 252 parse('42.__send__("`", "echo foo")').should be == [nil]
253 253 end
254 254
  255 + it "should raise a Solid::SyntaxError on unknown constructs" do
  256 + expect {
  257 + parse('{}[]')
  258 + }.to raise_error(Solid::SyntaxError)
  259 + end
  260 +
255 261 end
256 262
257 263 context 'with useless round brackets' do

0 comments on commit 03c6fab

Please sign in to comment.
Something went wrong with that request. Please try again.