module RestConnection::Errors
Public Class Methods
status_error(response)
click to toggle source
Messages for nicer exceptions, from rfc2616
# File lib/rest_connection.rb, line 355 def self.status_error(response) @errors ||= { 100 => [RestConnection::Errors::Continue, 'Continue'], 101 => [RestConnection::Errors::SwitchingProtocols, 'Switching Protocols'], 200 => [RestConnection::Errors::OK, 'OK'], 201 => [RestConnection::Errors::Created, 'Created'], 202 => [RestConnection::Errors::Accepted, 'Accepted'], 203 => [RestConnection::Errors::NonAuthoritativeInformation, 'Non-Authoritative Information'], 204 => [RestConnection::Errors::NoContent, 'No Content'], 205 => [RestConnection::Errors::ResetContent, 'Reset Content'], 206 => [RestConnection::Errors::PartialContent, 'Partial Content'], 300 => [RestConnection::Errors::MultipleChoices, 'Multiple Choices'], 301 => [RestConnection::Errors::MovedPermanently, 'Moved Permanently'], 302 => [RestConnection::Errors::Found, 'Found'], 303 => [RestConnection::Errors::SeeOther, 'See Other'], 304 => [RestConnection::Errors::NotModified, 'Not Modified'], 305 => [RestConnection::Errors::UseProxy, 'Use Proxy'], 307 => [RestConnection::Errors::TemporaryRedirect, 'Temporary Redirect'], 400 => [RestConnection::Errors::BadRequest, 'Bad Request'], 401 => [RestConnection::Errors::Unauthorized, 'Unauthorized'], 402 => [RestConnection::Errors::PaymentRequired, 'Payment Required'], 403 => [RestConnection::Errors::Forbidden, 'Forbidden'], 404 => [RestConnection::Errors::NotFound, 'Not Found'], 405 => [RestConnection::Errors::MethodNotAllowed, 'Method Not Allowed'], 406 => [RestConnection::Errors::NotAcceptable, 'Not Acceptable'], 407 => [RestConnection::Errors::ProxyAuthenticationRequired, 'Proxy Authentication Required'], 408 => [RestConnection::Errors::RequestTimeout, 'Request Timeout'], 409 => [RestConnection::Errors::Conflict, 'Conflict'], 410 => [RestConnection::Errors::Gone, 'Gone'], 411 => [RestConnection::Errors::LengthRequired, 'Length Required'], 412 => [RestConnection::Errors::PreconditionFailed, 'Precondition Failed'], 413 => [RestConnection::Errors::RequestEntityTooLarge, 'Request Entity Too Large'], 414 => [RestConnection::Errors::RequestURITooLong, 'Request-URI Too Long'], 415 => [RestConnection::Errors::UnsupportedMediaType, 'Unsupported Media Type'], 416 => [RestConnection::Errors::RequestedRangeNotSatisfiable, 'Request Range Not Satisfiable'], 417 => [RestConnection::Errors::ExpectationFailed, 'Expectation Failed'], 422 => [RestConnection::Errors::UnprocessableEntity, 'Unprocessable Entity'], 500 => [RestConnection::Errors::InternalServerError, 'InternalServerError'], 501 => [RestConnection::Errors::NotImplemented, 'Not Implemented'], 502 => [RestConnection::Errors::BadGateway, 'Bad Gateway'], 503 => [RestConnection::Errors::ServiceUnavailable, 'Service Unavailable'], 504 => [RestConnection::Errors::GatewayTimeout, 'Gateway Timeout'] } error, message = @errors[response.code.to_i] || [RestConnection::Errors::HTTPStatusError, 'Unknown'] error.new("Invalid response HTTP code: #{response.code.to_i}: #{response.body}", response) end