Sha256: d94f84c755d9ecdcca31772619b5547066cc978f0e35b4a711315ecb9ed851ae

Contents?: true

Size: 513 Bytes

Versions: 1

Compression:

Stored size: 513 Bytes

Contents

# frozen_string_literal: true

class Solid::Result::Contract::Error < Solid::Result::Error
  class UnexpectedType < self
    def self.build(type:, allowed_types:)
      new("type :#{type} is not allowed. Allowed types: #{allowed_types.map(&:inspect).join(', ')}")
    end
  end

  class UnexpectedValue < self
    def self.build(type:, value:, cause: nil)
      cause_message = " (#{cause.message})" if cause

      new("value #{value.inspect} is not allowed for :#{type} type#{cause_message}")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solid-result-2.0.0 lib/solid/result/contract/error.rb