Class: Dynflow::ExecutionPlan::Steps::Error
- Inherits:
-
Serializable
show all
- Extended by:
- Algebrick::Matching
- Includes:
- Algebrick::TypeCheck
- Defined in:
- lib/dynflow/execution_plan/steps/error.rb
Constant Summary
Constants inherited
from Serializable
Serializable::LEGACY_TIME_FORMAT, Serializable::TIME_FORMAT
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
constantize, from_hash
Constructor Details
#initialize(exception_class, message, backtrace, exception) ⇒ Error
27
28
29
30
31
32
|
# File 'lib/dynflow/execution_plan/steps/error.rb', line 27
def initialize(exception_class, message, backtrace, exception)
@exception_class = Child! exception_class, Exception
@message = Type! message, String
@backtrace = Type! backtrace, Array
@exception = Type! exception, Exception, NilClass
end
|
Instance Attribute Details
#backtrace ⇒ Object
Returns the value of attribute backtrace.
8
9
10
|
# File 'lib/dynflow/execution_plan/steps/error.rb', line 8
def backtrace
@backtrace
end
|
#exception_class ⇒ Object
Returns the value of attribute exception_class.
8
9
10
|
# File 'lib/dynflow/execution_plan/steps/error.rb', line 8
def exception_class
@exception_class
end
|
#message ⇒ Object
Returns the value of attribute message.
8
9
10
|
# File 'lib/dynflow/execution_plan/steps/error.rb', line 8
def message
@message
end
|
Class Method Details
.new(*args) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/dynflow/execution_plan/steps/error.rb', line 10
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.message, 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
34
35
36
37
38
39
40
41
|
# File 'lib/dynflow/execution_plan/steps/error.rb', line 34
def self.new_from_hash(hash)
exception_class = begin
Utils.constantize(hash[:exception_class])
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
57
58
59
60
|
# File 'lib/dynflow/execution_plan/steps/error.rb', line 57
def exception
@exception ||
exception_class.exception(message).tap { |e| e.set_backtrace backtrace }
end
|
#to_hash ⇒ Object
43
44
45
46
47
48
|
# File 'lib/dynflow/execution_plan/steps/error.rb', line 43
def to_hash
recursive_to_hash class: self.class.name,
exception_class: exception_class.to_s,
message: message,
backtrace: backtrace
end
|
#to_s ⇒ Object
50
51
52
53
54
55
|
# File 'lib/dynflow/execution_plan/steps/error.rb', line 50
def to_s
format '%s (%s)\n%s',
(@exception || self).message,
(@exception ? @exception.class : exception_class),
(@exception || self).backtrace
end
|