Sha256: e18af6ab62a4d5ff6121128059e1fa50ed2dcbffc674b40b2076bc24704094de

Contents?: true

Size: 742 Bytes

Versions: 19

Compression:

Stored size: 742 Bytes

Contents

module Finitio

  class Error < StandardError

    def initialize(msg, cause = nil)
      super(msg)
      @cause = cause
    end
    attr_reader :cause

    def root_cause(sandbox = true)
      # 1) no deeper cause, it's me
      return self if cause.nil?

      # 2) not a Finitio cause and sandbox
      return self if sandbox and not cause.is_a?(Error)

      # 3) cause may not go deeper
      return cause unless cause.respond_to?(:root_cause)

      # 4) delegate
      cause.root_cause
    end

  end # class Error

  class TypeError < Error

    def initialize(msg, cause = nil, location = nil)
      super(msg, cause)
      @location = location || ''
    end
    attr_reader :location

  end # class TypeError

end # module Finitio

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
finitio-0.12.0 lib/finitio/errors.rb
finitio-0.11.4 lib/finitio/errors.rb
finitio-0.11.3 lib/finitio/errors.rb
finitio-0.11.2 lib/finitio/errors.rb
finitio-0.11.1 lib/finitio/errors.rb
finitio-0.10.0 lib/finitio/errors.rb
finitio-0.9.1 lib/finitio/errors.rb
finitio-0.9.0 lib/finitio/errors.rb
finitio-0.8.0 lib/finitio/errors.rb
finitio-0.7.0 lib/finitio/errors.rb
finitio-0.7.0.pre.rc4 lib/finitio/errors.rb
finitio-0.7.0.pre.rc3 lib/finitio/errors.rb
finitio-0.7.0.pre.rc2 lib/finitio/errors.rb
finitio-0.7.0.pre.rc1 lib/finitio/errors.rb
finitio-0.6.1 lib/finitio/errors.rb
finitio-0.6.0 lib/finitio/errors.rb
finitio-0.5.2 lib/finitio/errors.rb
finitio-0.5.1 lib/finitio/errors.rb
finitio-0.5.0 lib/finitio/errors.rb