Module: Metanorma::Plugin::Lutaml::Utils::LiquidErrorCapturer

Defined in:
lib/metanorma/plugin/lutaml/utils.rb

Overview

Prepended to Liquid::Context to preserve the original exception that Liquid 5.x wraps as InternalError (discarding the cause).

Instance Method Summary collapse

Instance Method Details

#handle_error(e, line_number = nil) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/metanorma/plugin/lutaml/utils.rb', line 20

def handle_error(e, line_number = nil)
  if e.is_a?(::Liquid::Error)
    super
  else
    ie = ::Liquid::InternalError.new("internal")
    ie.set_backtrace(e.backtrace)
    ie.define_singleton_method(:original_error) { e }
    ie.template_name ||= template_name
    ie.line_number ||= line_number
    errors.push(ie)
    exception_renderer.call(ie).to_s
  end
end