Class: Dynflow::ExecutionPlan::Steps::Error
- Inherits:
-
Serializable
- Object
- Serializable
- Dynflow::ExecutionPlan::Steps::Error
- Extended by:
- Algebrick::Matching
- Includes:
- Algebrick::TypeCheck
- Defined in:
- lib/dynflow/execution_plan/steps/error.rb
Instance Attribute Summary collapse
-
#backtrace ⇒ Object
readonly
Returns the value of attribute backtrace.
-
#exception_class ⇒ Object
readonly
Returns the value of attribute exception_class.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Class Method Summary collapse
Instance Method Summary collapse
- #exception ⇒ Object
-
#initialize(exception_class, message, backtrace, exception) ⇒ Error
constructor
A new instance of Error.
- #to_hash ⇒ Object
- #to_s ⇒ Object
Methods inherited from Serializable
Constructor Details
#initialize(exception_class, message, backtrace, exception) ⇒ Error
Returns a new instance of Error.
26 27 28 29 30 31 |
# File 'lib/dynflow/execution_plan/steps/error.rb', line 26 def initialize(exception_class, , backtrace, exception) @exception_class = Child! exception_class, Exception @message = Type! , String @backtrace = Type! backtrace, Array @exception = Type! exception, Exception, NilClass end |
Instance Attribute Details
#backtrace ⇒ Object (readonly)
Returns the value of attribute backtrace.
7 8 9 |
# File 'lib/dynflow/execution_plan/steps/error.rb', line 7 def backtrace @backtrace end |
#exception_class ⇒ Object (readonly)
Returns the value of attribute exception_class.
7 8 9 |
# File 'lib/dynflow/execution_plan/steps/error.rb', line 7 def exception_class @exception_class end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
7 8 9 |
# File 'lib/dynflow/execution_plan/steps/error.rb', line 7 def @message end |
Class Method Details
.new(*args) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/dynflow/execution_plan/steps/error.rb', line 9 def self.new(*args) case args.size when 1 match obj = args.first, (on String do super(StandardError, obj, caller, nil) end), (on Exception do super(obj.class, obj., obj.backtrace, obj) end) when 3, 4 super(*args.values_at(0..3)) else raise ArgumentError, "wrong number of arguments #{args}" end end |
.new_from_hash(hash) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/dynflow/execution_plan/steps/error.rb', line 33 def self.new_from_hash(hash) exception_class = begin hash[:exception_class].constantize rescue NameError Errors::UnknownError.for_exception_class(hash[:exception_class]) end self.new(exception_class, hash[:message], hash[:backtrace], nil) end |
Instance Method Details
#exception ⇒ Object
56 57 58 59 |
# File 'lib/dynflow/execution_plan/steps/error.rb', line 56 def exception @exception || exception_class.exception().tap { |e| e.set_backtrace backtrace } end |
#to_hash ⇒ Object
42 43 44 45 46 47 |
# File 'lib/dynflow/execution_plan/steps/error.rb', line 42 def to_hash recursive_to_hash class: self.class.name, exception_class: exception_class.to_s, message: , backtrace: backtrace end |
#to_s ⇒ Object
49 50 51 52 53 54 |
# File 'lib/dynflow/execution_plan/steps/error.rb', line 49 def to_s format '%s (%s)\n%s', (@exception || self)., (@exception ? @exception.class : exception_class), (@exception || self).backtrace end |