trypandoc: better error handling.
This commit is contained in:
parent
b2d875e748
commit
7574bfda46
1 changed files with 8 additions and 1 deletions
|
@ -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 =>
|
||||
|
|
Loading…
Reference in a new issue