Method: Ruber::ExceptionDialog#initialize

Defined in:
lib/ruber/exception_widgets.rb

#initialize(ex, parent = nil, out = true, msg = 'Ruber raised the following exception:') ⇒ ExceptionDialog

Returns a new instance of ExceptionDialog.

Parameters:

  • ex (Exception)

    the exception the dialog is for

  • the (Qt::Widget, nil)

    parent widget

  • out (Boolean) (defaults to: true)

    whether to display the exception to standard error when the dialog is executed

  • msg (String) (defaults to: 'Ruber raised the following exception:')

    the text to display in the dialog before the exception message. Note that this will always be treated as rich text. Unless empty, a line break will always be inserted after it

[View source]

92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/ruber/exception_widgets.rb', line 92

def initialize ex, parent = nil, out = true, msg = 'Ruber raised the following exception:'
  super parent
  self.caption = KDE::Dialog.make_standard_caption "Exception"
  self.buttons = Ok | Details
  set_button_text Ok, 'Quit Ruber'
  set_button_text Details, 'Backtrace'
  error = ex.message.gsub(/\n/, '<br/>')
  error.gsub!(/[<>]/){|s| s == '<' ? '&lt;' : '&gt;'}
  text = (!msg.empty? ? msg + '<br/>' : '') + '<tt>' + error + '</tt>'
  self.main_widget = Qt::Label.new text, self
  @backtrace_widget = ExceptionBacktraceWidget.new ex, self
  self.details_widget = @backtrace_widget
  @out = out
end