Sha256: 52f8686e6950e096bef0dcda39270e8d471e3ef7c22e9b00a17f8c315ca5eb1f

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

module Pod4


  ## 
  # Raised in abstract methods when treated as concrete
  #
  class NotImplemented < Exception
    
    def initialize(msg=nil)
      super(msg || $! && $!.message)
    end

  end


  ##
  # Base error class for Swingshift
  #
  # Also used for any configuration errors where ArgumentError is not appropriate.
  #
  class Pod4Error < StandardError

    def initialize(msg=nil)
      super(msg || $! && $!.message)
      @cos = $!
    end

    unless defined?(cause)
      define_method(:cause) { @cos }
    end

  end
  ##


  ##
  # Raised if something goes wrong on the database
  #
  class DatabaseError < Pod4Error

    def initialize(msg=nil)
      super(msg || $! && $!.message)
    end

  end
  ##


  ##
  # Raised if a Pod4 method runs into problems
  #
  # Note, invalid parameters get a Ruby ArgumentError. This is for, eg, an interface finding that
  # the ID it was given to read does not exist.
  #
  class CantContinue < Pod4Error

    def initialize(msg=nil)
      super(msg || $! && $!.message)
    end

  end
  ##


  ##
  # Raised if validation fails (and you wanted an exception...)
  #
  class ValidationError < Pod4Error
    attr_reader :field

    def self.from_alert(alert)
      self.new(alert.message, alert.field)
    end

    def initialize(message=nil, field=nil)
      super(message || $! && $!.message)
      @field = field.to_s.to_sym
    end

  end


end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pod4-0.8.3 lib/pod4/errors.rb
pod4-0.8.2 lib/pod4/errors.rb
pod4-0.8.1 lib/pod4/errors.rb