Sha256: 748381a7ef5afe18f72bdd5518986a47a11908f4355d2d50592d3044e9c4678b
Contents?: true
Size: 1006 Bytes
Versions: 4
Compression:
Stored size: 1006 Bytes
Contents
module Flows class Result # Base class for Result errors. class Error < ::Flows::Error; end # Error for invalid data access cases class AccessError < Flows::Error def initialize(result) @result = result end def message [ base_msg, " Result status: `#{@result.status.inspect}`", " Result data: `#{data.inspect}`", " Result meta: `#{@result.meta.inspect}`" ].join("\n") end private def base_msg case @result when Flows::Result::Ok 'Data in a successful result must be retrieved using `#unwrap` method, not `#error`.' when Flows::Result::Err 'Data in a failure result must be retrieved using `#error` method, not `#unwrap`.' end end def data case @result when Flows::Result::Ok @result.unwrap when Flows::Result::Err @result.error end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
flows-0.6.0 | lib/flows/result/errors.rb |
flows-0.5.1 | lib/flows/result/errors.rb |
flows-0.5.0 | lib/flows/result/errors.rb |
flows-0.4.0 | lib/flows/result/errors.rb |