Class: Ruber::ExceptionDialog
- Defined in:
- lib/ruber/exception_widgets.rb
Overview
Dialog which displays the content of an exception (that is, the message and the backtrace) to the user.
The backtrace is shown as an extension widget, only if the user clicks the ‘Backtrace’ button.
Direct Known Subclasses
Defined Under Namespace
Classes: ExceptionBacktraceWidget
Instance Method Summary collapse
-
#exec ⇒ Integer
Override of @KDE::Dialog#exec@ .
-
#initialize(ex, parent = nil, out = true, msg = 'Ruber raised the following exception:') ⇒ ExceptionDialog
constructor
A new instance of ExceptionDialog.
-
#show ⇒ nil
Override of @KDE::Dialog#show@.
-
#sizeHint ⇒ Qt::Size
Override of @KDE::Dialog#sizeHint@.
Constructor Details
#initialize(ex, parent = nil, out = true, msg = 'Ruber raised the following exception:') ⇒ ExceptionDialog
Returns a new instance of ExceptionDialog.
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. = KDE::Dialog. "Exception" self. = Ok | Details Ok, 'Quit Ruber' Details, 'Backtrace' error = ex..gsub(/\n/, '<br/>') error.gsub!(/[<>]/){|s| s == '<' ? '<' : '>'} text = (!msg.empty? ? msg + '<br/>' : '') + '<tt>' + error + '</tt>' self. = Qt::Label.new text, self @backtrace_widget = ExceptionBacktraceWidget.new ex, self self. = @backtrace_widget @out = out end |
Instance Method Details
#exec ⇒ Integer
Override of @KDE::Dialog#exec@
If the out parameter passed to the constructor was true, displays the exception message and backtrace on standard error before displaying the dialog
133 134 135 136 137 138 |
# File 'lib/ruber/exception_widgets.rb', line 133 def exec if @out $stderr.puts @backtrace_widget.to_plain_text end super end |
#show ⇒ nil
Override of @KDE::Dialog#show@
If the out parameter passed to the constructor was true, displays the exception message and backtrace on standard error before displaying the dialog
147 148 149 150 151 152 |
# File 'lib/ruber/exception_widgets.rb', line 147 def show if @out $stderr.puts @backtrace_widget.to_plain_text end super end |
#sizeHint ⇒ Qt::Size
Override of @KDE::Dialog#sizeHint@
It takes into account the size of the details widget, if shown.
114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/ruber/exception_widgets.rb', line 114 def sizeHint orig = super if defined?(@backtrace_widget) and @backtrace_widget.visible? main_width = .sizeHint.width diff = orig.width - main_width det_width = @backtrace_widget.sizeHint.width w = [det_width, main_width].max + diff Qt::Size.new(w, orig.height) else orig end end |