Skip to content

Commit

Permalink
Merge pull request #510 from datacite/handle-response
Browse files Browse the repository at this point in the history
Handle wrong  format from handle server
  • Loading branch information
Martin Fenner authored May 13, 2020
2 parents 918a26f + 9968317 commit ba310e1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/jobs/url_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def perform(doi_id)

if doi.present?
response = Doi.get_doi(doi: doi.doi, agency: doi.agency)
url = response.body.dig('data', 'values', 0, 'data', 'value')
url = response.is_a?(String) ? nil : response.body.dig('data', 'values', 0, 'data', 'value')
if url.present?
if (doi.is_registered_or_findable? || %w(europ).include?(doi.provider_id)) && doi.minted.blank?
doi.update_attributes(url: url, minted: Time.zone.now)
Expand Down
1 change: 1 addition & 0 deletions app/models/concerns/helpable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def get_doi(options={})

Rails.logger.error "[Handle] " + text
User.send_notification_to_slack(text, title: "Error #{response.status.to_s}", level: "danger") unless Rails.env.test?
OpenStruct.new(status: 400, body: { "errors" => [{ "status" => 400, "title" => response.body["errors"].inspect }] })
end
end

Expand Down

0 comments on commit ba310e1

Please sign in to comment.