From 684bb147a21a3a9566722018c04bb11a889605bf Mon Sep 17 00:00:00 2001 From: Thorsten Vitt Date: Wed, 19 Aug 2020 22:46:47 +0200 Subject: [PATCH] gvfa: mproved error reporting --- src/graphviewer/gvfa.py | 6 ++++-- src/graphviewer/templates/form.html | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/graphviewer/gvfa.py b/src/graphviewer/gvfa.py index 89f42cc..1369e80 100644 --- a/src/graphviewer/gvfa.py +++ b/src/graphviewer/gvfa.py @@ -187,8 +187,10 @@ def agraph(nodeinfo: NodeInput = Depends(), reduction = nx.transitive_reduction(g) g = g.edge_subgraph([(u, v, k) for u, v, k, _ in expand_edges(g, reduction.edges)]) else: - raise ValueError( - 'Cannot produce transitive reduction – the subgraph is not acyclic after removing conflict edges!') + raise HTTPException(500, dict( + error="not-acyclic", + msg='Cannot produce transitive reduction – the subgraph is not acyclic after removing conflict edges!', + dot=write_dot(g, target=None, highlight=nodes).to_string())) g = simplify_timeline(g) diff --git a/src/graphviewer/templates/form.html b/src/graphviewer/templates/form.html index 94820b5..71a5cfb 100644 --- a/src/graphviewer/templates/form.html +++ b/src/graphviewer/templates/form.html @@ -207,8 +207,21 @@ }) //.then(() => message()) .catch(reason => { - addLongMessage(`
${reason}
`, "danger") - console.error(reason) + try { + const details = JSON.parse(reason).detail; + console.error(details); + if (details.msg) { + addLongMessage(details.msg, 'danger') + } else { + addLongMessage(`
${details}
`, "danger") + } + if (details.dot) { + graphviz.transition(transitionFactory).renderDot(details.dot); + } + } catch (e) { + addLongMessage(`
${reason}
`, "danger") + console.error(reason) + } }); updateURLs(formdata); if (formdata.get('dir').includes('B')) { // vertical layout