-
Notifications
You must be signed in to change notification settings - Fork 208
/
error.rb
31 lines (30 loc) · 1020 Bytes
/
error.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
module Interactor
# Internal: Error raised during Interactor::Context failure. The error stores
# a copy of the failed context for debugging purposes.
class Failure < StandardError
# Internal: Gets the Interactor::Context of the Interactor::Failure
# instance.
attr_reader :context
# Internal: Initialize an Interactor::Failure.
#
# context - An Interactor::Context to be stored within the
# Interactor::Failure instance. (default: nil)
#
# Examples
#
# Interactor::Failure.new
# # => #<Interactor::Failure: Interactor::Failure>
#
# context = Interactor::Context.new(foo: "bar")
# # => #<Interactor::Context foo="bar">
# Interactor::Failure.new(context)
# # => #<Interactor::Failure: #<Interactor::Context foo="bar">>
#
# raise Interactor::Failure, context
# # => Interactor::Failure: #<Interactor::Context foo="bar">
def initialize(context = nil)
@context = context
super
end
end
end