From e167703ba3ccaf45b10f34119d7bbfe9867809cf Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Mon, 30 Mar 2015 01:13:28 +0900 Subject: [PATCH] Fix bad SyntaxError into CompileError --- lib/hamlit/concerns/error.rb | 4 ++++ lib/hamlit/concerns/indentable.rb | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/hamlit/concerns/error.rb b/lib/hamlit/concerns/error.rb index 73d316c6..edec1c50 100644 --- a/lib/hamlit/concerns/error.rb +++ b/lib/hamlit/concerns/error.rb @@ -11,6 +11,10 @@ module Hamlit [:code, code] end + def assert!(message) + raise CompileError.new(message) + end + def assert_scan!(scanner, regexp) result = scanner.scan(regexp) unless result diff --git a/lib/hamlit/concerns/indentable.rb b/lib/hamlit/concerns/indentable.rb index 31aaa7c6..6a90e4d5 100644 --- a/lib/hamlit/concerns/indentable.rb +++ b/lib/hamlit/concerns/indentable.rb @@ -1,6 +1,10 @@ +require 'hamlit/concerns/error' + module Hamlit module Concerns module Indentable + include Concerns::Error + EOF = -1 def reset_indent @@ -26,7 +30,7 @@ module Hamlit width = line[/\A +/].to_s.length return (width + 1) / 2 unless strict - raise SyntaxError if width.odd? + assert!('Expected to count even-width indent') if width.odd? width / 2 end