Sha256: 39eaf91e2cf8f1dbad6fb08a64cd1f554ea79aa70490bbf25977992084032378
Contents?: true
Size: 1.68 KB
Versions: 1
Compression:
Stored size: 1.68 KB
Contents
# frozen_string_literal: true class Solid::Result::Error < StandardError def self.build(**_kargs) new end class NotImplemented < self end class MissingTypeArgument < self def initialize(_message = nil) super('A type (argument) is required to invoke the #on/#on_type method') end end class UnexpectedOutcome < self def self.build(outcome:, origin:, expected: nil) expected ||= 'Solid::Result::Success or Solid::Result::Failure' new("Unexpected outcome: #{outcome.inspect}. The #{origin} must return this object wrapped by #{expected}") end end class InvalidResultSource < self def self.build(given_result:, expected_source:) message = "You cannot call #and_then and return a result that does not belong to the same source!\n" \ "Expected source: #{expected_source.inspect}\n" \ "Given source: #{given_result.send(:source).inspect}\n" \ "Given result: #{given_result.inspect}" new(message) end end class InvalidSourceMethodArity < self def self.build(source:, method:, max_arity:) new("#{source.class}##{method.name} has unsupported arity (#{method.arity}). Expected 0..#{max_arity}") end end class UnhandledTypes < self def self.build(types:) source = types.size == 1 ? 'This was' : 'These were' new("You must handle all cases. #{source} not handled: #{types.map(&:inspect).join(', ')}") end end class CallableAndThenDisabled < self def initialize(_message = nil) super( 'You cannot use #and_then! as the feature is disabled. ' \ 'Please use Solid::Result.config.feature.enable!(:and_then!) to enable it.' ) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
solid-result-2.0.0 | lib/solid/result/error.rb |