Module: Fog::Errors

Defined in:
lib/fog/errors.rb

Defined Under Namespace

Classes: Accepted, BadGateway, BadRequest, Conflict, Continue, Created, ExpectationFailed, Forbidden, Found, GatewayTimeout, Gone, InternalServerError, LengthRequired, MethodNotAllowed, MovedPermanently, MultipleChoices, NoContent, NonAuthoritativeInformation, NotAcceptable, NotFound, NotImplemented, NotModified, OK, PartialContent, PaymentRequired, PreconditionFailed, ProxyAuthenticationRequired, RequestEntityTooLarge, RequestTimeout, RequestURITooLong, RequestedRangeNotSatisfiable, ResetContent, SeeOther, ServiceUnavailable, SwitchingProtocols, TemporaryRedirect, Unauthorized, UnsupportedMediaType, UseProxy

Class Method Summary collapse

Class Method Details

.status_error(expected, actual, response) ⇒ Object

Messages for nicer exceptions, from rfc2616



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/fog/errors.rb', line 44

def self.status_error(expected, actual, response)
  @errors ||= { 
    100 => Fog::Errors::Continue, 
    101 => Fog::Errors::SwitchingProtocols,
    200 => Fog::Errors::OK,
    201 => Fog::Errors::Created,
    202 => Fog::Errors::Accepted,
    203 => Fog::Errors::NonAuthoritativeInformation,
    204 => Fog::Errors::NoContent,
    205 => Fog::Errors::ResetContent,
    206 => Fog::Errors::PartialContent,
    300 => Fog::Errors::MultipleChoices,
    301 => Fog::Errors::MovedPermanently,
    302 => Fog::Errors::Found,
    303 => Fog::Errors::SeeOther,
    304 => Fog::Errors::NotModified,
    305 => Fog::Errors::UseProxy,
    307 => Fog::Errors::TemporaryRedirect,
    400 => Fog::Errors::BadRequest,
    401 => Fog::Errors::Unauthorized,
    402 => Fog::Errors::PaymentRequired,
    403 => Fog::Errors::Forbidden,
    404 => Fog::Errors::NotFound,
    405 => Fog::Errors::MethodNotAllowed,
    406 => Fog::Errors::NotAcceptable,
    407 => Fog::Errors::ProxyAuthenticationRequired,
    408 => Fog::Errors::RequestTimeout,
    409 => Fog::Errors::Conflict,
    410 => Fog::Errors::Gone,
    411 => Fog::Errors::LengthRequired,
    412 => Fog::Errors::PreconditionFailed,
    413 => Fog::Errors::RequestEntityTooLarge,
    414 => Fog::Errors::RequestURITooLong,
    415 => Fog::Errors::UnsupportedMediaType,
    416 => Fog::Errors::RequestedRangeNotSatisfiable,
    417 => Fog::Errors::ExpectationFailed,
    500 => Fog::Errors::InternalServerError,
    501 => Fog::Errors::NotImplemented,
    502 => Fog::Errors::BadGateway,
    503 => Fog::Errors::ServiceUnavailable,
    504 => Fog::Errors::GatewayTimeout
  }
  @messages ||= { 
    100 => 'Continue', 
    101 => 'Switching Protocols',
    200 => 'OK',
    201 =>'Created',
    202 => 'Accepted',
    203 => 'Non-Authoritative Information',
    204 => 'No Content',
    205 => 'Reset Content',
    206 => 'Partial Content',
    300 => 'Multiple Choices',
    301 => 'Moved Permanently',
    302 => 'Found',
    303 => 'See Other',
    304 => 'Not Modified',
    305 => 'Use Proxy',
    307 => 'Temporary Redirect',
    400 => 'Bad Request',
    401 => 'Unauthorized',
    402 => 'Payment Required',
    403 => 'Forbidden',
    404 => 'Not Found',
    405 => 'Method Not Allowed',
    406 => 'Not Acceptable',
    407 => 'Proxy Authentication Required',
    408 => 'Request Timeout',
    409 => 'Conflict',
    410 => 'Gone',
    411 => 'Length Required',
    412 => 'Precondition Failed',
    413 => 'Request Entity Too Large',
    414 => 'Request-URI Too Long',
    415 => 'Unsupported Media Type',
    416 => 'Requested Range Not Satisfiable',
    417 => 'Expectation Failed',
    500 => 'Internal Server Error',
    501 => 'Not Implemented',
    502 => 'Bad Gateway',
    503 => 'Service Unavailable',
    504 => 'Gateway Timeout'
  }
  @errors[actual].new("Expected(#{expected} #{@messages[expected]}) <=> Actual(#{actual} #{@messages[actual]}) #{response.inspect}")
end