lib/powertrack/streaming/stream.rb
# Returns an appropriate return value or exception according to the response
# obtained on an API request.
Returns an appropriate return value or exception according to the response
obtained on an API request.
Returns an appropriate return value or exception according to the response obtained on an API request .
def handle_api_response(status, error, body, ok=DEFAULT_OK_RESPONSE_STATUS)
      case status
      when nil
        raise PowerTrack::ConnectionError.new(error)
      when ok
        return nil if body.nil?
        parse_json_body(body) do |exception|
          raise PowerTrack::InvalidResponseError.new(ok, exception.message, body)
        end
      else
        raise PowerTrack::WithStatusPowerTrackError.build(status, error, parse_json_body(body))
      end
    end
def handle_api_response ( status , error , body , ok = DEFAULT_OK_RESPONSE_STATUS ) case status when nil raise PowerTrack :: ConnectionError . new ( error ) when ok return nil if body . nil? parse_json_body ( body ) do | exception | raise PowerTrack :: InvalidResponseError . new ( ok , exception . message , body ) end else raise PowerTrack :: WithStatusPowerTrackError . build ( status , error , parse_json_body ( body ) ) end end
Returns an appropriate return value or exception according to the response
obtained on an API request.
Returns an appropriate return value or exception according to the response obtained on an API request .
# connection issue # successful call: return the body unless there isn't any # invalid JSON response # specified response status
status
error
body
ok