diff --git a/app/jobs/url_job.rb b/app/jobs/url_job.rb index 9885ecc90..afe8c4753 100644 --- a/app/jobs/url_job.rb +++ b/app/jobs/url_job.rb @@ -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) diff --git a/app/models/concerns/helpable.rb b/app/models/concerns/helpable.rb index 2e3b1861b..ab62f42c2 100644 --- a/app/models/concerns/helpable.rb +++ b/app/models/concerns/helpable.rb @@ -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