diff --git a/lib/ontologies_api_client/collection.rb b/lib/ontologies_api_client/collection.rb index 5ef779b..a4d34c2 100644 --- a/lib/ontologies_api_client/collection.rb +++ b/lib/ontologies_api_client/collection.rb @@ -46,7 +46,7 @@ def uri_from_context(object, media_type) def entry_point(media_type, params = {}) params = { include: @include_attrs, display_links: false, display_context: false}.merge(params) federated_get(params) do |url| - uri_from_context(top_level_links(url), media_type) + uri_from_context(top_level_links(url), media_type) rescue nil end end diff --git a/lib/ontologies_api_client/request_federation.rb b/lib/ontologies_api_client/request_federation.rb index 26c6dad..458af90 100644 --- a/lib/ontologies_api_client/request_federation.rb +++ b/lib/ontologies_api_client/request_federation.rb @@ -16,7 +16,7 @@ def federated_get(params = {}, &link) begin HTTP.get(link.call(conn.url_prefix.to_s.chomp('/')), params, connection: conn) rescue StandardError => e - [OpenStruct.new(errors: "Problem retrieving #{link.call(conn.url_prefix.to_s.chomp('/'))}")] + [OpenStruct.new(errors: "Problem retrieving #{link.call(conn.url_prefix.to_s.chomp('/')) || conn.url_prefix}")] end end diff --git a/test/models/test_federation.rb b/test/models/test_federation.rb index f66d8db..4890af5 100644 --- a/test/models/test_federation.rb +++ b/test/models/test_federation.rb @@ -108,4 +108,15 @@ def test_federated_analytics analytics = LinkedData::Client::Analytics.last_month refute_empty analytics.onts end + + + def test_federation_ssl_error + WebMock.enable! + WebMock.stub_request(:get, "#{LinkedData::Client.settings.rest_url.chomp('/')}") + .to_raise(Faraday::SSLError) + ontologies_federate_one = LinkedData::Client::Models::Ontology.all(display_links: false, display_context: false, invalidate_cache: true) + + refute_nil ontologies_federate_one.first.errors + WebMock.disable! + end end \ No newline at end of file