Exception: Locomotive::Common::RendererException

Inherits:
DefaultException show all
Defined in:
lib/locomotive/common/exception.rb

Instance Attribute Summary collapse

Attributes inherited from DefaultException

#notifier

Instance Method Summary collapse

Methods inherited from DefaultException

#init_plugins

Constructor Details

#initialize(exception, name, template, liquid_context) ⇒ RendererException

Returns a new instance of RendererException.



38
39
40
41
42
43
# File 'lib/locomotive/common/exception.rb', line 38

def initialize(exception, name, template, liquid_context)
  self.name, self.template, self.liquid_context = name, template, liquid_context
  self.log_page_into_backtrace(exception)
  super(exception.message)
  self.set_backtrace(exception.backtrace)
end

Instance Attribute Details

#liquid_contextObject

Returns the value of attribute liquid_context.



36
37
38
# File 'lib/locomotive/common/exception.rb', line 36

def liquid_context
  @liquid_context
end

#nameObject

Returns the value of attribute name.



36
37
38
# File 'lib/locomotive/common/exception.rb', line 36

def name
  @name
end

#templateObject

Returns the value of attribute template.



36
37
38
# File 'lib/locomotive/common/exception.rb', line 36

def template
  @template
end

Instance Method Details

#log_page_into_backtrace(exception) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/locomotive/common/exception.rb', line 45

def log_page_into_backtrace(exception)
  line = self.template.line_offset
  line += (exception.respond_to?(:line) ? exception.line || 0 : 0) + 1
  message = "#{self.template.filepath}:#{line}:in `#{self.name}'"
  notifier.fatal "[ERROR] #{exception.message} - #{message}\n".red
  exception.backtrace.unshift message
end