lib/fire_cloud_client.rb
# return a more user-friendly error message
#
# * *params*
#   - +error+ (RestClient::Exception) => an RestClient error object
#
# * *return*
#   - +String+ representation of complete error message, with http body if present
return a more user-friendly error message
*params
+error+ (RestClient::Exception) => an RestClient error object

*return
+String+ representation of complete error message, with http body if present
return a more user - friendly error message * params + error + ( RestClient :: Exception ) = > an RestClient error object * return + String + representation of complete error message with http body if present
def parse_error_message(error)
    if error.http_body.blank?
      error.message
    else
      begin
        error_hash = JSON.parse(error.http_body)
        if error_hash.has_key?('message')
          message = error_hash['message']
          if message.index('{').nil?
            return message
          else
            json_start = message.index('{')
            json = message[json_start, message.size + 1]
            new_message = JSON.parse(json)
            if new_message.has_key?('message')
              new_message['message']
            else
              new_message
            end
          end
        else
          return error.message
        end
      rescue => e
        Rails.logger.error e.message
        error.message + ': ' + error.http_body
      end
    end
  end
def parse_error_message ( error ) if error . http_body . blank? error . message else begin error_hash = JSON . parse ( error . http_body ) if error_hash . has_key? ( 'message' ) message = error_hash [ 'message' ] if message . index ( '{' ) . nil? return message else json_start = message . index ( '{' ) json = message [ json_start , message . size + 1 ] new_message = JSON . parse ( json ) if new_message . has_key? ( 'message' ) new_message [ 'message' ] else new_message end end else return error . message end rescue => e Rails . logger . error e . message error . message + ': ' + error . http_body end end end
return a more user-friendly error message
 *params
 +error+ (RestClient::Exception) => an RestClient error object
return a more user - friendly error message * params + error + ( RestClient :: Exception ) = > an RestClient error object
# check if hash can be parsed further # attempt to extract nested JSON from message
error
<not_specific>