Sha256: 909b80d5ffb29846d57b754b62d33508444f94e7cd3b7bcdec05a38093b13c20

Contents?: true

Size: 884 Bytes

Versions: 4

Compression:

Stored size: 884 Bytes

Contents

# frozen_string_literal: true

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

              super(message)
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
convenient_service-0.16.0 lib/convenient_service/service/plugins/raises_on_double_result/exceptions.rb
convenient_service-0.15.0 lib/convenient_service/service/plugins/raises_on_double_result/exceptions.rb
convenient_service-0.14.0 lib/convenient_service/service/plugins/raises_on_double_result/exceptions.rb
convenient_service-0.13.0 lib/convenient_service/service/plugins/raises_on_double_result/exceptions.rb