Exception: ConvenientService::Service::Plugins::HasJSendResultShortSyntax::Failure::Exceptions::KwargsContainJSendAndExtraKeys

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

Instance Method Summary collapse

Methods inherited from Exception

new

Instance Method Details

#initialize_without_argumentsvoid

This method returns an undefined value.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/convenient_service/service/plugins/has_j_send_result_short_syntax/failure/exceptions.rb', line 13

def initialize_without_arguments
  message = <<~TEXT
    `kwargs` passed to `failure` method contain JSend keys and extra keys. That's NOT allowed.

    Please, consider something like:

    # Shorter form with one arg. Assumes that arg is `message`.
    failure("foo")

    # Shorter form with two args. Assumes that first arg is `message` and second is `code`.
    failure("foo", :foo)

    # Shorter form with kwargs. Assumes that all kwargs are `data`.
    failure(foo: :bar)

    # Longer form. More explicit `message`.
    failure(message: "foo")

    # Longer form. More explicit `code`.
    failure(code: :foo)

    # Longer form. More explicit `message` and `code` together.
    failure(message: "foo", code: :foo)

    # (Advanced) Longer form also supports any other variation of `data`, `message` and `code`.
    failure(data: {foo: :bar}, message: "foo")
    failure(data: {foo: :bar}, code: :foo)
    failure(data: {foo: :bar}, message: "foo", code: :foo)
  TEXT

  initialize(message)
end