Skip to content

Commit c82e145

Browse files
committed
Raise APIRateLimitError if the status means too many request returns
1 parent 335793e commit c82e145

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/statistics/client.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module Statistics
22
class Client
3+
class APIRateLimitError < ::StandardError; end
4+
35
class_attribute :debug
46
self.debug = false
57

@@ -99,6 +101,12 @@ def fetch_events(group_id:, since_at: @default_since, until_at: @default_until)
99101
end
100102

101103
events
104+
rescue Faraday::ClientError => e
105+
if e.response[:status] == 429
106+
raise Client::APIRateLimitError
107+
else
108+
raise e
109+
end
102110
end
103111
end
104112
end

0 commit comments

Comments
 (0)