Module: Tzispa::Helpers::ErrorView

Defined in:
lib/tzispa/helpers/error_view.rb

Constant Summary collapse

ERROR_HEADER =
<<-ERRORHEADER
<head>
<meta charset="utf-8" />
<style> html {background:#cccccc; font-family:Arial; font-size:15px; color:#555;} body {width:75%; max-width:1200px; margin:18px auto; background:#fff; border-radius:6px; padding:32px 24px;} #main {margin:auto; } ul{list-style:none; margin:0; padding:0;} li{font-style:italic; color:#666;} h1 {color:#2ECC71;} </style>
</head>
ERRORHEADER
ERROR_PLATFORM_VERSIONS =
<<-ERRORPVERSION
<h6>#{Tzispa::FRAMEWORK_NAME} #{Tzispa::VERSION}</h6>
ERRORPVERSION

Instance Method Summary collapse

Instance Method Details

#debug_info(ex = nil, status: 500) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/tzispa/helpers/error_view.rb', line 22

def debug_info(ex = nil, status: 500)
  String.new.tap do |text|
    text << '<!DOCTYPE html><html lang="es">'
    text << ERROR_HEADER << '<body>'
    text << ERROR_PLATFORM_VERSIONS
    text << if ex
              srx = Tzispa::Helpers::Services::ErrorView.new ex
              "<h1>#{srx.error_header}\n #{srx.error_backtrace_list}"
            else
              "<h1>Error #{status}</h1>\nSe ha producido un error indeterminado"
            end
    text << '</body></html>'
  end
end

#error_defaultObject



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/tzispa/helpers/error_view.rb', line 50

def error_default
  String.new.tap do |text|
    text << '<!DOCTYPE html><html lang="es">'
    text << ERROR_HEADER << '<body>'
    text << '</head><body>'
    text << '<div id="main">'
    text << ERROR_PLATFORM_VERSIONS
    text << "<h1>Error #{status}</h1>\n"
    text << '</div>'
    text << '</body></html>'
  end
end

#error_log(ex) ⇒ Object



46
47
48
# File 'lib/tzispa/helpers/error_view.rb', line 46

def error_log(ex)
  Tzispa::Helpers::Services::ErrorView.new(ex).error_backtrace_log
end

#error_page(domain, status: 500) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/tzispa/helpers/error_view.rb', line 37

def error_page(domain, status: 500)
  error_file = "#{domain.path}/error/#{status}.htm"
  if (ef = Tzispa::Rig::File.new(error_file)) && ef.exist?
    ef.load!.content
  else
    error_default
  end
end