Resource limits: Don't raise Error but render error message (but abort after first error)

This commit is contained in:
Florian Weingarten
2013-05-31 09:25:25 -04:00
parent 8760b5e8c4
commit 9075b428b1
3 changed files with 22 additions and 7 deletions
+2 -2
View File
@@ -108,9 +108,9 @@ module Liquid
token_output = (token.respond_to?(:render) ? token.render(context) : token)
context.resource_limits[:render_length_current] += (token_output.respond_to?(:length) ? token_output.length : 1)
raise Liquid::MemoryError, context.resource_limits if context.resource_limits_reached?
raise MemoryError.new("Memory limits exceeded") if context.resource_limits_reached?
output << token_output
rescue Liquid::MemoryError => e
rescue MemoryError => e
raise e
rescue ::StandardError => e
output << (context.handle_error(e))
+3 -1
View File
@@ -120,9 +120,11 @@ module Liquid
begin
# render the nodelist.
# for performance reasons we get a array back here. join will make a string out of it
# for performance reasons we get an array back here. join will make a string out of it.
result = @root.render(context)
result.respond_to?(:join) ? result.join : result
rescue Liquid::MemoryError => e
context.handle_error(e)
ensure
@errors = context.errors
end