Method: Ruber::ExceptionDialog::ExceptionBacktraceWidget#initialize

Defined in:
lib/ruber/exception_widgets.rb

#initialize(ex, parent = nil) ⇒ ExceptionBacktraceWidget

Returns a new instance of ExceptionBacktraceWidget.

Parameters:

  • the exception whose backtrace should be displayed

  • (defaults to: nil)

    the parent widget



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/ruber/exception_widgets.rb', line 50

def initialize ex, parent = nil
  super parent
  self.line_wrap_mode = NoWrap
  self.read_only = true
  #Replace < and > with the corresponding HTML entities in the message
  msg = ex.message.gsub(/[<>]/){|s| s == '<' ? '&lt;' : '&gt;'}
  #Replace < and > with the corresponding HTML entities in the backtrace
  backtrace = ex.backtrace.map{|l| l.gsub(/[<>]/){|s| s == '<' ? '&lt;' : '&gt;'}}
  text = "<tt>#{msg}<br/>#{backtrace.join '<br/>'}</tt>"
  self.html = text
end