From 7574bfda46ce3a1b433543c7dbf069a8951b03c0 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 18 Aug 2022 13:58:02 -0700 Subject: [PATCH] trypandoc: better error handling. --- trypandoc/trypandoc.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/trypandoc/trypandoc.js b/trypandoc/trypandoc.js index 59f606f03..8d34c338b 100644 --- a/trypandoc/trypandoc.js +++ b/trypandoc/trypandoc.js @@ -55,6 +55,12 @@ function handleErrors(response) { if (!response.ok) { throw Error(response.statusText); } + if (response.status == 300) { + throw Error("Conversion timed out.") + } + if (response.status != 200) { + throw Error("Server returned status " + response.status.toString()) + } return response; } @@ -71,7 +77,8 @@ function convert() { fetch("/cgi-bin/pandoc-server.cgi/version") .then(handleErrors) .catch(error => - document.getElementById("results").textContent = error + document.getElementById("results").textContent = error; + return Promise.reject(); ) .then(response => response.text()) .then(restext =>