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

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

Instance Method Summary collapse

Methods inherited from Exception

new

Instance Method Details

#initialize_without_argumentsvoid

This method returns an undefined value.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/convenient_service/service/plugins/has_j_send_result_short_syntax/error/exceptions.rb', line 34

def initialize_without_arguments
  message = <<~TEXT
    `kwargs` passed to `error` 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`.
    error("foo")

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

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

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

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

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

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

  initialize(message)
end