From 8f45647aa37d784163980e9e23e4e515d5ecfd70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20L=C3=BCtke?= Date: Thu, 8 May 2008 12:35:17 -0400 Subject: [PATCH] Parse time errors should propagate to calling site --- lib/liquid/context.rb | 8 +++++--- test/error_handling_test.rb | 8 ++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/liquid/context.rb b/lib/liquid/context.rb index e420bf1..82eb843 100644 --- a/lib/liquid/context.rb +++ b/lib/liquid/context.rb @@ -42,10 +42,12 @@ module Liquid def handle_error(e) errors.push(e) raise if @rethrow_errors - + case e - when SyntaxError then "Liquid syntax error: #{e.message}" - else "Liquid error: #{e.message}" + when SyntaxError + "Liquid syntax error: #{e.message}" + else + "Liquid error: #{e.message}" end end diff --git a/test/error_handling_test.rb b/test/error_handling_test.rb index 5fee03d..b361d54 100644 --- a/test/error_handling_test.rb +++ b/test/error_handling_test.rb @@ -59,15 +59,11 @@ class ErrorHandlingTest < Test::Unit::TestCase end - def test_missing_endtag + def test_missing_endtag_parse_time_error - assert_nothing_raised do + assert_raise(Liquid::SyntaxError) do template = Liquid::Template.parse(' {% for a in b %} ... ') - assert_equal ' Liquid error: Unknown operator =! ', template.render - - assert_equal 1, template.errors.size - assert_equal Liquid::SyntaxError, template.errors.first.class end