aboutsummaryrefslogtreecommitdiff
path: root/gn3/api/metadata.py
diff options
context:
space:
mode:
Diffstat (limited to 'gn3/api/metadata.py')
-rw-r--r--gn3/api/metadata.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/gn3/api/metadata.py b/gn3/api/metadata.py
index 4fe9e67..680d51b 100644
--- a/gn3/api/metadata.py
+++ b/gn3/api/metadata.py
@@ -1,4 +1,5 @@
"""API for fetching metadata using an API"""
+from http.client import RemoteDisconnected
from flask import Blueprint
from flask import jsonify
from flask import current_app
@@ -14,9 +15,14 @@ metadata = Blueprint("metadata", __name__)
@metadata.route("/dataset/<accession_id>", methods=["GET"])
def jsonify_dataset_metadata(accession_id):
"""Fetch a dataset's metadata given it's ACCESSION_ID"""
- return jsonify(get_dataset_metadata(
- SPARQLWrapper(current_app
- .config
- .get("SPARQL_ENDPOINT")),
- accession_id
- ).data)
+ try:
+ return jsonify(
+ get_dataset_metadata(
+ SPARQLWrapper(current_app.config.get("SPARQL_ENDPOINT")),
+ accession_id,
+ ).data
+ )
+ # The virtuoso server is misconfigured or it isn't running at all
+ except RemoteDisconnected:
+ return jsonify({})
+