Class: Marver::API::ErrorHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/marver/api/errors.rb

Instance Method Summary collapse

Constructor Details

#initialize(ex) ⇒ ErrorHandler

Returns a new instance of ErrorHandler.



4
5
6
# File 'lib/marver/api/errors.rb', line 4

def initialize(ex)
  @message = ex.response['status']
end

Instance Method Details

#handle!Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/marver/api/errors.rb', line 8

def handle!
  case @code
  when 401
    raise Marver::Error::CredentialsFault.new(@message)
  when 403
    raise Marver::Error::MethodNotAllowed.new(@message)
  when 404
    raise Marver::Error::NotFound.new(@message)
  when 405
    raise Marver::Error::Forbidden.new(@message)
  when 409
    raise Marver::Error::Conflict.new(@message)
  end
end