Module: Dirigible::Utils
- Defined in:
- lib/dirigible/utils.rb
Class Method Summary collapse
Class Method Details
.handle_api_error(response) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/dirigible/utils.rb', line 4 def self.handle_api_error(response) error = case response.status when 400 then BadRequest.new when 401 then .new when 404 then NotFound.new when 405 then MethodNotAllowed.new when 406 then NotAcceptable.new else Error.new end error.error = parse_json(response.body) raise error end |
.parse_json(json) ⇒ Object
17 18 19 |
# File 'lib/dirigible/utils.rb', line 17 def self.parse_json(json) MultiJson.load(json, symbolize_keys: true) end |