Trypandoc: better error handling.
This commit is contained in:
parent
d01c507f25
commit
3c87b31f4b
1 changed files with 11 additions and 0 deletions
|
@ -212,6 +212,13 @@ function paramsFromURL() {
|
|||
}
|
||||
}
|
||||
|
||||
function handleErrors(response) {
|
||||
if (!response.ok) {
|
||||
throw Error(response.statusText);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
function convert() {
|
||||
let text = document.getElementById("text").value;
|
||||
let from = document.getElementById("from").value;
|
||||
|
@ -223,6 +230,10 @@ function convert() {
|
|||
|
||||
if (text && text != "") {
|
||||
fetch("/cgi-bin/pandoc-server.cgi/version")
|
||||
.then(handleErrors)
|
||||
.catch(error =>
|
||||
document.getElementById("results").textContent = error
|
||||
)
|
||||
.then(response => response.text())
|
||||
.then(restext =>
|
||||
document.getElementById("version").textContent = restext
|
||||
|
|
Loading…
Reference in a new issue