Sha256: 2dbf4c9a39d43150c7f0fbe24b9706e7cfbef9d747edf288b7f2ca98b066cc0d

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 KB

Contents

module IMW

  # Base error class which all IMW errors subclass.
  Error = Class.new(StandardError)

  # Method undefined.
  NoMethodError = Class.new(Error)

  # Type error.
  TypeError = Class.new(Error)

  # Not implemented (typically because user needs to define a method
  # when subclassing a base class).
  NotImplementedError = Class.new(Error)

  # Error during parsing.
  ParseError = Class.new(Error)

  # Error with a non-existing, invalid, or inaccessible path.
  PathError = Class.new(Error)

  # Error communicating with a remote entity.
  NetworkError = Class.new(Error)

  # Error communicating with a remote entity.
  ArgumentError = Class.new(Error)

  # Error in defining or matching a schema.
  SchemaError = Class.new(Error)

  # An error meant to be used when a system call goes awry.  It will
  # report exit status and the process id of the offending call.
  class SystemCallError < IMW::Error

    attr_reader :status, :message

    def initialize(status, message)
      @status  = status
      @message = message
    end

    def display
      "(error code: #{status.exitstatus}, pid: #{status.pid}) #{message}"
    end

    def to_s
      "(error code: #{status.exitstatus}, pid: #{status.pid}) #{message}"
    end

  end


end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
imw-0.2.9 lib/imw/utils/error.rb
imw-0.2.8 lib/imw/utils/error.rb