6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/strava/base_connection.rb', line 6
def fetch(relative_uri, options)
response = nil
begin
response = self.class.get("/#{relative_uri}", :query => options)
rescue HTTParty::UnsupportedFormat, HTTParty::UnsupportedURIScheme, HTTParty::ResponseError, HTTParty::RedirectionTooDeep
raise RequestError.new
rescue Exception => e
raise NetworkError.new(e)
end
case response.code
when 500...600
raise StravaError.new
when 404
raise '404ed'
when 200
return response.parsed_response
end
raise NetworkError.new('Bad status ' + response.code.to_s)
end
|