Skip to content

Commit

Permalink
Started handling all network-related exceptions (closes #76)
Browse files Browse the repository at this point in the history
  • Loading branch information
fblundun committed Aug 5, 2015
1 parent 334fad8 commit 74987ae
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions lib/snowplow-tracker/emitters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,18 @@ def flush(sync=false)
def send_requests(evts)
LOGGER.info("Attempting to send #{@buffer.size} request#{@buffer.size == 1 ? '' : 's'}")


if @method == 'post'
request = http_post({
'schema' => 'iglu:com.snowplowanalytics.snowplow/payload_data/jsonschema/1-0-2',
'data' => evts
})
if is_good_status_code(request.code)
post_succeeded = false
begin
request = http_post({
'schema' => 'iglu:com.snowplowanalytics.snowplow/payload_data/jsonschema/1-0-2',
'data' => evts
})
post_succeeded = is_good_status_code(request.code)
rescue StandardError => se
LOGGER.warn(se)
end
if post_succeeded
unless @on_success.nil?
@on_success.call(evts.size)
end
Expand All @@ -128,8 +133,13 @@ def send_requests(evts)
success_count = 0
unsent_requests = []
evts.each do |evt|
request = http_get(evt)
get_succeeded = is_good_status_code(request.code)
get_succeeded = false
begin
request = http_get(evt)
get_succeeded = is_good_status_code(request)
rescue StandardError => se
LOGGER.warn(se)
end
if get_succeeded
success_count += 1
else
Expand Down

0 comments on commit 74987ae

Please sign in to comment.