Sha256: 76a1f6a2810daa0fe587cd3fd414535e2af6f5e3b8e7b1a9cbc8c9e70e1a979e

Contents?: true

Size: 1.42 KB

Versions: 6

Compression:

Stored size: 1.42 KB

Contents

module ASIR
  # Generic API error.
  class Error < ::Exception
    # Subclass should override method.
    class SubclassResponsibility < self; end

    # Unsupported Feature.
    class Unsupported < self; end

    # Unimplemented Feature.
    class Unimplemented < self; end

    # Requested Stop.
    class Terminate < self; end

    # Unrecoverable Errors.
    class Unrecoverable < self
      def self.modules;    @@modules; end
      def self.modules= x; @@modules = x; end
      @@modules ||= [ self ]
    end

    # Fatal Errors.
    class Fatal < Unrecoverable; end

    # Unforwardable Exception.
    #
    # This encapsulates an Exception that should never be
    # forwarded and re-thrown directly in the client.
    # E.g.: SystemExit, Interrupt.
    class Unforwardable < self
      attr_accessor :original
      def initialize msg, original = nil, *args
        if ::Exception === msg
          original ||= msg
          msg = "#{original.class.name} #{msg.message}"
        end
        @original = original
        super(msg)
        self.set_backtrace original && original.backtrace
      end
      def self.unforwardable;    @@unforwardable; end
      def self.unforwardable= x; @@unforwardable = x; end
      @@unforwardable ||= [
        ::SystemExit,
        ::SystemStackError,
        ::NoMemoryError,
        ::Interrupt,
        ::SignalException,
        Error::Terminate,
        Error::Unrecoverable,
      ]
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
asir-1.2.8 lib/asir/error.rb
asir-1.2.7 lib/asir/error.rb
asir-1.2.6 lib/asir/error.rb
asir-1.2.5 lib/asir/error.rb
asir-1.2.3 lib/asir/error.rb
asir-1.2.2 lib/asir/error.rb