class DeltaCloud::HTTPError::ExceptionHandler
Attributes
http_status_code[R]
message[R]
trace[R]
Public Class Methods
new(status_code, message=nil, opts={}, backtrace=nil, &block)
click to toggle source
# File lib/errors.rb, line 67 def initialize(status_code, message=nil, opts={}, backtrace=nil, &block) @http_status_code = status_code.to_i @trace = backtrace @message = message || client_error_messages[status_code] || 'No error message received' @options = opts instance_eval(&block) if block_given? end
Public Instance Methods
on(code, exception_class)
click to toggle source
# File lib/errors.rb, line 75 def on(code, exception_class) if code == @http_status_code raise exception_class.new(code, @message, @options, @trace) end end
Private Instance Methods
client_error_messages()
click to toggle source
# File lib/errors.rb, line 83 def client_error_messages { 400 => 'The request could not be understood by the server due to malformed syntax.', 401 => 'Authentication required for this request or invalid credentials provided.', 403 => 'Requested operation is not allowed for this resource.', 404 => 'Not Found', 405 => 'Method not allowed for this resource.', 406 => 'Requested media type is not supported by server.', 408 => 'The client did not produce a request within the time that the server was prepared to wait.', 410 => 'The resource is no longer available' } end