Exception: ConvenientService::Service::Plugins::ForbidsConvenientServiceEntitiesAsConstructorArguments::Exceptions::MessagePassedAsConstructorArgument

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

Instance Method Summary collapse

Methods inherited from Exception

new

Instance Method Details

#initialize_with_kwargs(selector:, service:, message:) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/convenient_service/service/plugins/forbids_convenient_service_entities_as_constructor_arguments/exceptions.rb', line 70

def initialize_with_kwargs(selector:, service:, message:)
  exception_message = <<~TEXT
    Message of `#{Utils::Class.display_name(message.result.service.class)}` result is passed as constructor argument `#{selector}` to `#{Utils::Class.display_name(service.class)}`.

    It is an antipattern. It neglects the idea of steps.

    Please, convert it to string or try to reorganize `#{Utils::Class.display_name(service.class)}` service.
  TEXT

  initialize(exception_message)
end