Sha256: 6394a0759e0ba4fd10ba71253986beabefcf2b13c196837a32370bbd6f2e91a0

Contents?: true

Size: 901 Bytes

Versions: 4

Compression:

Stored size: 901 Bytes

Contents

# frozen_string_literal: true

module ConvenientService
  module Service
    module Plugins
      module RaisesOnDoubleResult
        module Exceptions
          class DoubleResult < ::ConvenientService::Exception
            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
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
convenient_service-0.19.1 lib/convenient_service/service/plugins/raises_on_double_result/exceptions.rb
convenient_service-0.19.0 lib/convenient_service/service/plugins/raises_on_double_result/exceptions.rb
convenient_service-0.18.0 lib/convenient_service/service/plugins/raises_on_double_result/exceptions.rb
convenient_service-0.17.0 lib/convenient_service/service/plugins/raises_on_double_result/exceptions.rb