Skip to content

Commit

Permalink
improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Mar 7, 2020
1 parent d40775c commit cc06f10
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions app/controllers/export_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def contacts
send_data csv, filename: "contacts-#{Date.today}.csv"
end
end
rescue Elasticsearch::Transport::Transport::Errors::BadRequest => exception
rescue StandardError, Elasticsearch::Transport::Transport::Errors::BadRequest => exception
Raven.capture_exception(exception)

message = JSON.parse(exception.message[6..-1]).to_h.dig("error", "root_cause", 0, "reason")
Expand Down Expand Up @@ -138,8 +138,8 @@ def organizations
"billingCity",
"Department",
"billingOrganization",
"billingState",
"billingCountry",
"billingStateCode",
"billingCountryCode",
"twitter",
"ROR",
"Fabrica Creation Date",
Expand Down Expand Up @@ -168,8 +168,8 @@ def organizations
billingCity: provider.billing_city,
billingDepartment: provider.billing_department,
billingOrganization: provider.billing_organization,
billingState: provider.billing_state,
billingCountry: provider.billing_country,
billingStateCode: provider.billing_state,
billingCountryCode: provider.billing_country,
twitter: provider.twitter_handle,
rorId: provider.ror_id,
created: provider.created.strftime(EXPORT_DATE_FORMAT),
Expand All @@ -183,7 +183,7 @@ def organizations
send_data csv, filename: "organizations-#{Date.today}.csv"
end
end
rescue Elasticsearch::Transport::Transport::Errors::BadRequest => exception
rescue StandardError, Elasticsearch::Transport::Transport::Errors::BadRequest => exception
Raven.capture_exception(exception)

message = JSON.parse(exception.message[6..-1]).to_h.dig("error", "root_cause", 0, "reason")
Expand Down Expand Up @@ -214,7 +214,7 @@ def repositories
page_num += 1
end

# Get doi counts via DOIS query and combine next to clients.
# Get doi counts via DOIs query and combine next to clients.
response = Doi.query(nil, state: "registered,findable", page: { size: 0, number: 1}, totals_agg: "client")

client_totals = {}
Expand Down Expand Up @@ -283,7 +283,7 @@ def repositories
send_data csv, filename: "repositories-#{Date.today}.csv"
end
end
rescue Elasticsearch::Transport::Transport::Errors::BadRequest => exception
rescue StandardError, Elasticsearch::Transport::Transport::Errors::BadRequest => exception
Raven.capture_exception(exception)

message = JSON.parse(exception.message[6..-1]).to_h.dig("error", "root_cause", 0, "reason")
Expand Down

0 comments on commit cc06f10

Please sign in to comment.