Sha256: 60a94f29a6e7d5ce004071dcdeeafd664b70864144e1d6f973a1b6a3ea78ade3

Contents?: true

Size: 1.7 KB

Versions: 1

Compression:

Stored size: 1.7 KB

Contents

module RoomoramaApi
	module Api
  	module Errors

  		#According to https://www.roomorama.com/api/documentation

  		class BadRequest < StandardError
  			def initialize
  				super("Bad Request")
  			end	
  		end
		  
		  class Unauthorized < StandardError
  	   	def initialize
  	   		super("You're not authorized to access this resource, make sure you're sending the right authorization header in your request")
  	   	end	
		  end
		    
		  class General < StandardError
  	   	def initialize
  	   		super("Generic error")
  	   	end	
		  end
    
		  class Unavailable < StandardError
  	   	def initialize
  	   		super("Unavailable")
  	   	end	
		  end
    
		  class UnprocessableEntity < StandardError
  	   	def initialize
  	   		super("Something went wrong while saving or updating your object, make sure the data you're sending in the request is correct")
  	   	end	
		  end
    
		  class InternalError < StandardError
  	   	def initialize
  	   		super("An error has occurred in Roomorama service")
  	   	end	
		  end
    
		  class NotFound  < StandardError
  	   	def initialize
  	   		super("The resource doesn't exist")
  	   	end	
		  end
    
		  class Conflict  < StandardError
  	   	def initialize
  	   		super("The request cannot be performed because of the state the resource is in")
  	   	end	
		  end
    
		  # HTTP code => error class mapping
    
  	  HTTP_STATUS_ERRORS = {
  	  	400 => BadRequest,
  	  	401 => Unauthorized,
  	  	403 => General,
  	  	404 => NotFound,
  	  	409 => Conflict,
  	  	422 => UnprocessableEntity,
  	  	500 => InternalError,
  	  	502 => Unavailable,
  	  	503 => Unavailable
  	  }

  	end # end module Errors 
  end # end module Api
end # end module RoomoramaApi
  			

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
roomorama_api-0.4.1 lib/roomorama_api/api/errors.rb