Module: Tzispa::Helpers::ErrorView
- Defined in:
- lib/tzispa/helpers/error_view.rb
Instance Method Summary collapse
Instance Method Details
#debug_info(exception = nil, status: 500) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/tzispa/helpers/error_view.rb', line 8 def debug_info(exception=nil, status: 500) String.new.tap { |text| text << '<!DOCTYPE html>' text << '<html lang="es"><head>' text << '<meta charset="utf-8" />' text << '<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;} ul{list-style:none; margin:0; padding:0;} li{font-style:italic; color:#666;} h1 {color:#2ECC71;} </style>' text << '</head><body>' text << "<h5>#{Tzispa::FRAMEWORK_NAME} #{Tzispa::VERSION}</h5>\n" if exception text << "<h1>#{exception.class.name}</h1><h3>#{exception.message}</h1>\n" text << '<ol>' + exception.backtrace.map { |trace| "<li>#{trace}</li>\n" }.join + '</ol>' if exception.respond_to?(:backtrace) && exception.backtrace else text << "<h1>Error #{status}</h1>\n" text << "Se ha producido un error inesperado al tramitar la petición" end text << '</body></html>' } end |
#error_page(domain, status: 500) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/tzispa/helpers/error_view.rb', line 27 def error_page(domain, status: 500) begin error_file = "#{domain.path}/error/#{status}.htm" Tzispa::Rig::File.new(error_file).load!.content rescue String.new.tap { |text| text << '<!DOCTYPE html>' text << '<html lang="es"><head>' text << '<meta charset="utf-8" />' text << '<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; } h1 {color:#2ECC71; font-size:4em; text-align:center;} </style>' text << '</head><body>' text << '<div id="main">' text << "<h5>#{Tzispa::FRAMEWORK_NAME} #{Tzispa::VERSION}</h5>\n" text << "<h1>Error #{status}</h1>\n" text << '</div>' text << '</body></html>' } end end |