mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-02 16:45:12 -07:00
Merge pull request #1776 from Shopify/refactor/invalid-encoding-error
add new TemplateEncodingError
This commit is contained in:
+16
-15
@@ -40,19 +40,20 @@ module Liquid
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
ArgumentError = Class.new(Error)
|
ArgumentError = Class.new(Error)
|
||||||
ContextError = Class.new(Error)
|
ContextError = Class.new(Error)
|
||||||
FileSystemError = Class.new(Error)
|
FileSystemError = Class.new(Error)
|
||||||
StandardError = Class.new(Error)
|
StandardError = Class.new(Error)
|
||||||
SyntaxError = Class.new(Error)
|
SyntaxError = Class.new(Error)
|
||||||
StackLevelError = Class.new(Error)
|
StackLevelError = Class.new(Error)
|
||||||
MemoryError = Class.new(Error)
|
MemoryError = Class.new(Error)
|
||||||
ZeroDivisionError = Class.new(Error)
|
ZeroDivisionError = Class.new(Error)
|
||||||
FloatDomainError = Class.new(Error)
|
FloatDomainError = Class.new(Error)
|
||||||
UndefinedVariable = Class.new(Error)
|
UndefinedVariable = Class.new(Error)
|
||||||
UndefinedDropMethod = Class.new(Error)
|
UndefinedDropMethod = Class.new(Error)
|
||||||
UndefinedFilter = Class.new(Error)
|
UndefinedFilter = Class.new(Error)
|
||||||
MethodOverrideError = Class.new(Error)
|
MethodOverrideError = Class.new(Error)
|
||||||
DisabledError = Class.new(Error)
|
DisabledError = Class.new(Error)
|
||||||
InternalError = Class.new(Error)
|
InternalError = Class.new(Error)
|
||||||
|
TemplateEncodingError = Class.new(Error)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ module Liquid
|
|||||||
source = source.to_s.to_str
|
source = source.to_s.to_str
|
||||||
|
|
||||||
unless source.valid_encoding?
|
unless source.valid_encoding?
|
||||||
raise SyntaxError, parse_context.locale.t("errors.syntax.invalid_template_encoding")
|
raise TemplateEncodingError, parse_context.locale.t("errors.syntax.invalid_template_encoding")
|
||||||
end
|
end
|
||||||
|
|
||||||
tokenizer = parse_context.new_tokenizer(source, start_line_number: @line_numbers && 1)
|
tokenizer = parse_context.new_tokenizer(source, start_line_number: @line_numbers && 1)
|
||||||
|
|||||||
@@ -339,7 +339,7 @@ class TemplateTest < Minitest::Test
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_raises_error_with_invalid_utf8
|
def test_raises_error_with_invalid_utf8
|
||||||
e = assert_raises(SyntaxError) do
|
e = assert_raises(TemplateEncodingError) do
|
||||||
Template.parse(<<~LIQUID)
|
Template.parse(<<~LIQUID)
|
||||||
{% comment %}
|
{% comment %}
|
||||||
\xC0
|
\xC0
|
||||||
@@ -347,7 +347,7 @@ class TemplateTest < Minitest::Test
|
|||||||
LIQUID
|
LIQUID
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal('Liquid syntax error: Invalid template encoding', e.message)
|
assert_equal('Liquid error: Invalid template encoding', e.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_allows_non_string_values_as_source
|
def test_allows_non_string_values_as_source
|
||||||
|
|||||||
Reference in New Issue
Block a user