Class: Waw::ErrorHandler::Backtrace
- Defined in:
- lib/waw/controllers/error/backtrace.rb
Instance Method Summary collapse
-
#call(kernel, ex) ⇒ Object
Shows a page with a friendly presented backtrace for the error that occured.
-
#ex_backtrace_to_html(backtrace) ⇒ Object
Converts a back-trace to a friendly HTML chunck.
-
#ex_to_html(ex, backtrace) ⇒ Object
Converts an exception to a friendly HTML chunck.
Instance Method Details
#call(kernel, ex) ⇒ Object
Shows a page with a friendly presented backtrace for the error that occured
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/waw/controllers/error/backtrace.rb', line 40 def call(kernel, ex) backtrace = case ex when ::WLang::Error ex.wlang_backtrace when ::Exception ex.backtrace else [] end [500, {'Content-Type' => 'text/html'}, ex_to_html(ex, backtrace)] end |
#ex_backtrace_to_html(backtrace) ⇒ Object
Converts a back-trace to a friendly HTML chunck
7 8 9 |
# File 'lib/waw/controllers/error/backtrace.rb', line 7 def ex_backtrace_to_html(backtrace) "<div>" + backtrace.collect{|s| CGI.escapeHTML(s)}.join('</div><div>') + "</div>" end |
#ex_to_html(ex, backtrace) ⇒ Object
Converts an exception to a friendly HTML chunck
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/waw/controllers/error/backtrace.rb', line 12 def ex_to_html(ex, backtrace) <<-EOF <html> <head> <style type="text/css"> body { font-size: 14px; font-family: "Courier", "Arial", sans-serif; } p.message { font-size: 16px; font-weight: bold; } </style> </head> <body> <h1>Internal server error (ruby exception)</h1> <p class="message"><code>#{CGI.escapeHTML(ex.)}</code></p> <div style="margin-left:50px;"> #{ex_backtrace_to_html(backtrace)} </div> </body> </html> EOF end |