Class: Rooibos::Message::Error
- Inherits:
-
Data
- Object
- Data
- Rooibos::Message::Error
- Includes:
- Predicates
- Defined in:
- lib/rooibos/message/error.rb
Overview
Error message from a failed command.
Commands run in background threads. Exceptions bubble up silently. Your update function never sees them. Backtraces in STDERR corrupt the TUI.
The runtime catches exceptions and wraps them in Error messages. Pattern match on Error in your update function. Display the error, log it, or recover.
Use it to surface failures from HTTP requests, file I/O, or external processes.
Examples
Update = ->(, model) {
case
in { type: :error, command:, exception: }
# Show error toast
model.with(error: exception.)
in Message::Error
# Store for later inspection
model.with(last_error: .exception)
end
}
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
Instance Method Summary collapse
-
#deconstruct_keys(_keys) ⇒ Object
Deconstructs for pattern matching.
-
#error? ⇒ Boolean
Returns
truefor error messages.
Methods included from Predicates
#==, #method_missing, #respond_to_missing?, #to_sym
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Rooibos::Message::Predicates
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command
32 33 34 |
# File 'lib/rooibos/message/error.rb', line 32 def command @command end |
#exception ⇒ Object (readonly)
Returns the value of attribute exception
32 33 34 |
# File 'lib/rooibos/message/error.rb', line 32 def exception @exception end |
Instance Method Details
#deconstruct_keys(_keys) ⇒ Object
Deconstructs for pattern matching.
Returns a hash with type, command, and exception.
43 44 45 |
# File 'lib/rooibos/message/error.rb', line 43 def deconstruct_keys(_keys) { type: :error, command:, exception: } end |
#error? ⇒ Boolean
Returns true for error messages.
36 37 38 |
# File 'lib/rooibos/message/error.rb', line 36 def error? true end |