Sha256: b9e14fb15bbc325f8880475a01bb872aee3e68487292837cadb94b8a462b7b3b

Contents?: true

Size: 1.97 KB

Versions: 2

Compression:

Stored size: 1.97 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Service
    module Plugins
      module CanHaveSteps
        module Entities
          class Step
            module Plugins
              module CanHaveFallbacks
                module Exceptions
                  class FallbackResultIsNotOverridden < ::ConvenientService::Exception
                    ##
                    # @param step [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step]
                    # @param service [ConvenientService::Service]
                    # @param status [Symbol]
                    # @return [void]
                    #
                    def initialize_with_kwargs(step:, service:, status:)
                      message = <<~TEXT
                        Neither `fallback_#{status}_result` nor `fallback_result` methods of `#{service.class}` are overridden, but the step is marked to be fallbacked.

                        Either override one of those methods or remove the `fallback` option from the corresponding step definition in `#{step.container.klass}`.
                      TEXT

                      initialize(message)
                    end
                  end

                  class MethodStepCanNotHaveFallback < ::ConvenientService::Exception
                    ##
                    # @param step [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step]
                    # @return [void]
                    #
                    def initialize_with_kwargs(step:)
                      message = <<~TEXT
                        Method step can NOT have fallback.

                        Either remove `fallback` option from step `:#{step.method}` in `#{step.container.klass}` or consider to refactor it into a service step.
                      TEXT

                      initialize(message)
                    end
                  end
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
convenient_service-0.19.1 lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_fallbacks/exceptions.rb
convenient_service-0.19.0 lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_fallbacks/exceptions.rb