Sha256: 5bfd046c977a813fa72204322f006c8ad7400f0a564fab567e940ab46d4fe303

Contents?: true

Size: 1.39 KB

Versions: 3

Compression:

Stored size: 1.39 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.modules;    @@modules; end
      def self.modules= x; @@modules = x; end
      @@modules ||= [
        ::SystemExit,
        ::SystemStackError,
        ::NoMemoryError,
        ::Interrupt,
        ::SignalException,
        Error::Terminate,
        Error::Unrecoverable,
      ]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
asir-1.2.11 lib/asir/error.rb
asir-1.2.10 lib/asir/error.rb
asir-1.2.9 lib/asir/error.rb