Class: Brut::TUI::Events::Exception
- Defined in:
- lib/brut/tui/events/exception.rb
Overview
Fired when an exception is caught. In general, your code should endeavor to catch exceptions, wrap them in this, and fir it.
You can control if the app should exit by setting fatal: true when
creating the event. Note that by default, all exceptions are treated
as fatal, since you generally don't want to use them for control flow.
Instance Attribute Summary collapse
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
Instance Method Summary collapse
-
#deconstruct_keys(keys = nil) ⇒ Object
Includes
exception, which is the exception that triggered this event. -
#drain_then_exit? ⇒ Boolean
Returns true if this event is not considered fatal.
-
#exit? ⇒ Boolean
By default, all exceptions should cause an immediate exit.
-
#initialize(exception) ⇒ Exception
constructor
A new instance of Exception.
Methods inherited from BaseEvent
Constructor Details
#initialize(exception) ⇒ Exception
Returns a new instance of Exception.
9 10 11 |
# File 'lib/brut/tui/events/exception.rb', line 9 def initialize(exception) @exception = exception end |
Instance Attribute Details
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
8 9 10 |
# File 'lib/brut/tui/events/exception.rb', line 8 def exception @exception end |
Instance Method Details
#deconstruct_keys(keys = nil) ⇒ Object
Includes exception, which is the exception that triggered this event.
21 22 23 |
# File 'lib/brut/tui/events/exception.rb', line 21 def deconstruct_keys(keys=nil) super.merge({ exception: @exception}) end |
#drain_then_exit? ⇒ Boolean
Returns true if this event is not considered fatal.
14 |
# File 'lib/brut/tui/events/exception.rb', line 14 def drain_then_exit? = !exit? |
#exit? ⇒ Boolean
By default, all exceptions should cause an immediate exit. You may subclass this event to do
something different, noting that #drain_then_exit? returns true if this returns false.
18 |
# File 'lib/brut/tui/events/exception.rb', line 18 def exit? = true |