Sha256: c1011961457470fa031ae2f1eb1d7d2f7bcfcd8d18500dffb6ed8964eb706bee
Contents?: true
Size: 1.61 KB
Versions: 8
Compression:
Stored size: 1.61 KB
Contents
module Locomotive module Common class DefaultException < ::Exception attr_accessor :notifier def initialize(message = nil, parent_exception = nil) self.notifier = Locomotive::Common.configuration.notifier self.log_backtrace(parent_exception) if parent_exception super(message) init_plugins end def init_plugins begin @plugins = [] ::Plugins.constants.each do |name| @plugins << ::Plugins.const_get(name).new(self) end rescue NameError end end protected def log_backtrace(parent_exception) full_error_message = "#{parent_exception.message}\n\t" full_error_message += parent_exception.backtrace.join("\n\t") full_error_message += "\n\n" notifier.fatal full_error_message end end class RendererException < DefaultException attr_accessor :name, :template, :liquid_context 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 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 end end end
Version data entries
8 entries across 8 versions & 1 rubygems