Sha256: 383f1ee6a307febdbbffec8b22d5d4d4a801839906047234fdd1af7b429310f6

Contents?: true

Size: 874 Bytes

Versions: 14

Compression:

Stored size: 874 Bytes

Contents

# frozen_string_literal: true

module ConvenientService
  module Service
    module Plugins
      module RaisesOnDoubleResult
        module Errors
          class DoubleResult < ConvenientService::Error
            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

14 entries across 14 versions & 1 rubygems

Version Path
convenient_service-0.11.0 lib/convenient_service/service/plugins/raises_on_double_result/errors.rb
convenient_service-0.10.1 lib/convenient_service/service/plugins/raises_on_double_result/errors.rb
convenient_service-0.10.0 lib/convenient_service/service/plugins/raises_on_double_result/errors.rb
convenient_service-0.9.0 lib/convenient_service/service/plugins/raises_on_double_result/errors.rb
convenient_service-0.8.0 lib/convenient_service/service/plugins/raises_on_double_result/errors.rb
convenient_service-0.7.0 lib/convenient_service/service/plugins/raises_on_double_result/errors.rb
convenient_service-0.6.0 lib/convenient_service/service/plugins/raises_on_double_result/errors.rb
convenient_service-0.5.0 lib/convenient_service/service/plugins/raises_on_double_result/errors.rb
convenient_service-0.4.0 lib/convenient_service/service/plugins/raises_on_double_result/errors.rb
convenient_service-0.3.1 lib/convenient_service/service/plugins/raises_on_double_result/errors.rb
convenient_service-0.3.0 lib/convenient_service/service/plugins/raises_on_double_result/errors.rb
convenient_service-0.2.1 lib/convenient_service/service/plugins/raises_on_double_result/errors.rb
convenient_service-0.2.0 lib/convenient_service/service/plugins/raises_on_double_result/errors.rb
convenient_service-0.1.0 lib/convenient_service/service/plugins/raises_on_double_result/errors.rb