aboutsummaryrefslogtreecommitdiff
path: root/gn2/wqflask
diff options
context:
space:
mode:
authorMunyoki Kilyungi2024-08-29 12:57:13 +0300
committerBonfaceKilz2024-08-29 14:51:30 +0300
commit50fb34a131a762cbe4e7fe8e19e7eb9dd13aa249 (patch)
tree4add3255aaddc56cbe308c904e83318a329fed3e /gn2/wqflask
parent3285757d2e5846089ed1f688e4f9cf448dde378a (diff)
downloadgenenetwork2-50fb34a131a762cbe4e7fe8e19e7eb9dd13aa249.tar.gz
Handle errors correctly during wiki entry fetch.
* gn2/wqflask/templates/wiki/genewiki.html: Flash messages during errors. * gn2/wqflask/views.py (display_genewiki_page): Use "raise_for_status()" to handle errors. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'gn2/wqflask')
-rw-r--r--gn2/wqflask/templates/wiki/genewiki.html1
-rw-r--r--gn2/wqflask/views.py16
2 files changed, 12 insertions, 5 deletions
diff --git a/gn2/wqflask/templates/wiki/genewiki.html b/gn2/wqflask/templates/wiki/genewiki.html
index 63f36741..496f5e28 100644
--- a/gn2/wqflask/templates/wiki/genewiki.html
+++ b/gn2/wqflask/templates/wiki/genewiki.html
@@ -1,6 +1,7 @@
{% extends "base.html" %}
{% block title %}GeneWiki Entry for {{ symbol }}{% endblock %}
{% block content %}
+ {{ flash_me() }}
<div class = "container">
<h1 class = "page-header">GeneWiki Entries</h1>
<p>
diff --git a/gn2/wqflask/views.py b/gn2/wqflask/views.py
index d40cfdb7..4e3c556d 100644
--- a/gn2/wqflask/views.py
+++ b/gn2/wqflask/views.py
@@ -1223,12 +1223,18 @@ def display_diffs_users():
@app.route("/genewiki/<string:symbol>")
def display_genewiki_page(symbol: str):
"""Fetch GeneRIF metadata from GN3 and display it"""
- wiki = requests.get(
- urljoin(
- GN3_LOCAL_URL,
- f"/api/metadata/wiki/{symbol}"
+ wiki = {}
+ try:
+ wiki = requests.get(
+ urljoin(
+ GN3_LOCAL_URL,
+ f"/api/metadata/wiki/{symbol}"
+ )
)
- ).json()
+ wiki.raise_for_status()
+ wiki = wiki.json()
+ except requests.RequestException as excp:
+ flash(excp, "alert-warning")
return render_template(
"wiki/genewiki.html",
symbol=symbol,