Class: Bijou::ErrorFormatterHTML
- Inherits:
-
ErrorFormatter
- Object
- ErrorFormatter
- Bijou::ErrorFormatterHTML
- Defined in:
- lib/bijou/errorformatter.rb
Instance Attribute Summary
Attributes inherited from ErrorFormatter
#error, #errors, #stack, #title, #warnings
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from ErrorFormatter
find_eval_line, format_error, get_file_context, get_source_file_line, #initialize, #set_context
Constructor Details
This class inherits a constructor from Bijou::ErrorFormatter
Class Method Details
.style ⇒ Object
314 315 316 317 318 319 320 |
# File 'lib/bijou/errorformatter.rb', line 314 def self.style return " body { font-family: Arial,sans-serif; } pre { font-family: Courier New,monospace; } pre strong { color: red; } " end |
Instance Method Details
#format ⇒ Object
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
# File 'lib/bijou/errorformatter.rb', line 250 def format result = '' # Lead with the error message. result << "<h3>Message</h3>\n" result << "<pre>" result << ::CGI::escapeHTML($!.to_s) result << "</pre>\n" # # The error description. # # result << "\n\n" # if @error # This should be $! if set. # result << "<pre>" # result << error # result << "</pre>\n" # end errors.each {|m| result << "<div>" result << ::CGI::escapeHTML(m.text) result << "</div>\n" } warnings.each {|m| result << "<div>" result << ::CGI::escapeHTML(m.text) result << "</div>\n" } if @error_line && @context_lines.length > 0 # Show where it occurred result << "<h3>Context</h3>\n" result << "<pre>\n" digits = Integer(Math.log10(@error_line + @adjacent_lines) + 1) @context_lines.each {|line| if @error_line == line['number'] result << '<strong>' end result << sprintf("%*d: %s\n", digits, line['number'], ::CGI::escapeHTML(line['text'])) if @error_line == line['number'] result << "</strong>" if @error_column > 0 result << sprintf("%*s\n", digits + 1 + @error_column, '^') end end } result << "</pre>\n" end result << "<h3>Stack</h3>\n" stack.each {|m| result << "<div>" result << ::CGI::escapeHTML(m.to_s) result << "</div>\n" } return result end |