Sha256: 4ec9379ef7cc2da61c77db5de2140a1f14646948b233e438dc28270c32a70cd3

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

module AMEE
  
  class ArgumentError < Exception
  end

  class BadData < Exception
    def initialize(msg = nil)
      super(msg)
      @msg = msg
      @last_err = $!
    end
    def to_s
      if @last_err
        ([@msg, @last_err.message]+@last_err.backtrace).join "\n"
      else
        super
      end
    end
  end
  
  class BadRequest < Exception
  end

  class AuthFailed < Exception  
  end

  class PermissionDenied < Exception
  end

  class ConnectionFailed < Exception
  end
  
  class NotFound < Exception
  end
  
  class DuplicateResource < Exception
  end

  class UnknownError < Exception
  end

  class NotSupported < Exception
  end

  class Deprecated < Exception
  end
  
  # These are used to classify exceptions that can occur during parsing
  
  module XMLParseError
  end
  
  module JSONParseError
  end
  
end

# Set up possible XML parse errors
[
  ArgumentError, # thrown by Date.parse
].each do |m| 
  m.send(:include, AMEE::XMLParseError)
end

# Set up possible JSON parse errors
[
  ArgumentError, # thrown by Date.parse,
  NoMethodError, # missing elements in JSON, thrown by nil[]
].each do |m| 
  m.send(:include, AMEE::JSONParseError)
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
amee-2.7.0 lib/amee/exceptions.rb
amee-2.6.0 lib/amee/exceptions.rb