Class: Tzispa::Helpers::Services::ErrorView

Inherits:
Object
  • Object
show all
Defined in:
lib/tzispa/helpers/services/error_view.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exception) ⇒ ErrorView

Returns a new instance of ErrorView.



10
11
12
# File 'lib/tzispa/helpers/services/error_view.rb', line 10

def initialize(exception)
  @exception = exception
end

Instance Attribute Details

#exceptionObject (readonly)

Returns the value of attribute exception.



8
9
10
# File 'lib/tzispa/helpers/services/error_view.rb', line 8

def exception
  @exception
end

Instance Method Details

#error_backtrace_listObject



18
19
20
21
22
23
24
25
# File 'lib/tzispa/helpers/services/error_view.rb', line 18

def error_backtrace_list
  return unless exception.respond_to?(:backtrace) && exception.backtrace
  String.new.tap do |str|
    str << '<ol>'
    str << exception.backtrace.map { |trace| "<li>#{trace}</li>\n" }.join
    str << '</ol>'
  end
end

#error_backtrace_logObject



27
28
29
30
31
32
33
# File 'lib/tzispa/helpers/services/error_view.rb', line 27

def error_backtrace_log
  return unless exception.respond_to?(:backtrace) && exception.backtrace
  String.new.tap do |str|
    str << "#{exception.class.name}: #{exception}:\n"
    str << exception.backtrace.join("\n")
  end
end

#error_headerObject



14
15
16
# File 'lib/tzispa/helpers/services/error_view.rb', line 14

def error_header
  "<h1>#{exception.class.name}</h1><h3>#{exception.message}</h3>"
end