Exception: ConvenientService::Service::Plugins::RaisesOnDoubleResult::Exceptions::DoubleResult

Inherits:
Exception
  • Object
show all
Defined in:
lib/convenient_service/service/plugins/raises_on_double_result/exceptions.rb

Instance Method Summary collapse

Methods inherited from Exception

new

Instance Method Details

#initialize_with_kwargs(service:) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/convenient_service/service/plugins/raises_on_double_result/exceptions.rb', line 9

def initialize_with_kwargs(service:)
  message = <<~TEXT
    `#{service.class}` service has a double result.

    Make sure its #result calls only one from the following methods `success`, `failure`, or `error` and only once.

    Maybe you missed `return`? The most common scenario is similar to this one:

    def result
      # ...

      error unless valid?
      # instead of return error unless valid?

      success
    end
  TEXT

  initialize(message)
end