Sha256: 8f58fb78ed09fbee7aec11ae80d5c89cdd3d99351d253f37f3eef4713db4f529

Contents?: true

Size: 1.31 KB

Versions: 18

Compression:

Stored size: 1.31 KB

Contents

# Copyright (C) 2008-2011 AMEE UK Ltd. - http://www.amee.com
# Released as Open Source Software under the BSD 3-Clause license. See LICENSE.txt for details.

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

18 entries across 18 versions & 1 rubygems

Version Path
amee-4.3.2 lib/amee/exceptions.rb
amee-4.3.1 lib/amee/exceptions.rb
amee-4.3.0 lib/amee/exceptions.rb
amee-4.2.0 lib/amee/exceptions.rb
amee-3.2.1 lib/amee/exceptions.rb
amee-3.2.0 lib/amee/exceptions.rb
amee-4.1.7 lib/amee/exceptions.rb
amee-4.1.6 lib/amee/exceptions.rb
amee-4.1.5 lib/amee/exceptions.rb
amee-4.1.4 lib/amee/exceptions.rb
amee-4.1.3 lib/amee/exceptions.rb
amee-3.1.2 lib/amee/exceptions.rb
amee-3.1.1 lib/amee/exceptions.rb
amee-4.1.2 lib/amee/exceptions.rb
amee-4.1.1 lib/amee/exceptions.rb
amee-4.1.0 lib/amee/exceptions.rb
amee-4.0.0 lib/amee/exceptions.rb
amee-3.0.1 lib/amee/exceptions.rb