Class: Heroku::Client::JSONUtil
- Inherits:
-
Object
- Object
- Heroku::Client::JSONUtil
- Defined in:
- lib/heroku-client/json_util.rb
Instance Method Summary collapse
- #parse_error(body) ⇒ Object
- #parse_json_error(body) ⇒ Object
- #parse_plain_text_error(body) ⇒ Object
- #parse_response(body) ⇒ Object
Instance Method Details
#parse_error(body) ⇒ Object
5 6 7 |
# File 'lib/heroku-client/json_util.rb', line 5 def parse_error(body) parse_json_error(body) || parse_plain_text_error(body) end |
#parse_json_error(body) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/heroku-client/json_util.rb', line 9 def parse_json_error(body) json = JSON.parse body rescue false case json when Array json.first.join ' ' # message like [["name", "is already taken"]] when Hash json['error'] # message like {"error": "The error message"} end end |
#parse_plain_text_error(body) ⇒ Object
20 21 22 |
# File 'lib/heroku-client/json_util.rb', line 20 def parse_plain_text_error(body) body end |