1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/joyent/errors.rb
Paul Thornthwaite a72433d2f8 Remove duplicate requires from services
Following work on reorganising the requires, there was an inconsistent
approach to where service wrappers are required. (Fog::Compute...)

Since they should be standardised and shared across providers (although
they really aren't yet) they have been moved to `fog-core` gem.

Each provider has their own `lib/fog/{provider}/core` files that is
required by each of their services. These files should all require
`fog/core` which already required most or these.

So this removes the extra cases to concentrate them in core.
2014-02-13 17:44:48 +00:00

92 lines
2.9 KiB
Ruby

require 'fog/joyent/core'
module Fog
module Compute
class Joyent < Fog::Service
class Errors
module MessageParserMixin
def message
if response.body["code"] && response.body["message"]
"[ERROR #{response.body['code']}] : #{response.body['message']}"
else
''
end
end
def to_s
message
end
end
# https://us-west-1.api.joyentcloud.com/docs#cloudapi-http-responses
#
# HTTP Status Codes
#
# Your client should check for each of the following status codes from any API request:
#
# Response Code Description
# 400 Bad Request Invalid HTTP Request
class BadRequest < Excon::Errors::BadRequest
include MessageParserMixin
end
# 401 Unauthorized Either no Authorization header was sent, or invalid credentials were used
class Unauthorized < Excon::Errors::Unauthorized
include MessageParserMixin
end
# 403 Forbidden No permissions to the specified resource
class Forbidden < Excon::Errors::Forbidden
include MessageParserMixin
end
# 404 Not Found Something you requested was not found
class NotFound < Excon::Errors::NotFound
include MessageParserMixin
end
# 405 Method Not Allowed Method not supported for the given resource
class MethodNotAllowed < Excon::Errors::MethodNotAllowed
include MessageParserMixin
end
# 406 Not Acceptable Try sending a different Accept header
class NotAcceptable < Excon::Errors::NotAcceptable
include MessageParserMixin
end
# 409 Conflict Most likely invalid or missing parameters
class Conflict < Excon::Errors::Conflict
include MessageParserMixin
end
# 413 Request Entity Too Large You sent too much data
class RequestEntityTooLarge < Excon::Errors::RequestEntityTooLarge
include MessageParserMixin
end
# 415 Unsupported Media Type You encoded your request in a format we don't understand
class UnsupportedMediaType < Excon::Errors::UnsupportedMediaType
include MessageParserMixin
end
# 420 Slow Down You're sending too many requests
class PolicyNotForfilled < Excon::Errors::HTTPStatusError
include MessageParserMixin
end
# 449 Retry With Invalid Version header; try with a different X-Api-Version string
class RetryWith < Excon::Errors::HTTPStatusError
include MessageParserMixin
end
# 503 Service Unavailable Either there's no capacity in this datacenter, or we're in a maintenance window
class ServiceUnavailable < Excon::Errors::ServiceUnavailable
include MessageParserMixin
end
end
end
end
end