From 2a6ce96ea1567b1bcd458de5ef8683cd395309ad Mon Sep 17 00:00:00 2001
From: Paul Millar <paul.millar@desy.de>
Date: Sun, 29 Dec 2024 09:26:58 +0100
Subject: [PATCH] update_oai-pmh robust against metadata prefix lookup failures

Motivation:

The ListMetadataFormats call can fail.  Currently, this causes the enire
script to fail.

Modification:

Catch the exception and report a failure.

Result:

A metadata prefix lookup failure is now limited to a single
OAI-PMH endpoint
---
 scripts/update_oai-pmh.rb | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/scripts/update_oai-pmh.rb b/scripts/update_oai-pmh.rb
index e20a528..9da1dca 100644
--- a/scripts/update_oai-pmh.rb
+++ b/scripts/update_oai-pmh.rb
@@ -346,7 +346,12 @@ def query_oai_pmh_endpoint(endpoint)
         return status, [], {}, 0, {}
     end
 
-    dc_prefix = metadata_prefix_of(endpoint, 'http://www.openarchives.org/OAI/2.0/oai_dc/')
+    begin
+        dc_prefix = metadata_prefix_of(endpoint, 'http://www.openarchives.org/OAI/2.0/oai_dc/')
+    rescue StandardError => e
+        print_with_time("Error: metadata_prefix_of failed: #{e.message}")
+        return "Error", [], {}, 0, {}
+    end
 
     set_names = list_sets(endpoint)
 
-- 
GitLab