From 9fac4a968e52b0e9a441bf8b8ceddb7543f03541 Mon Sep 17 00:00:00 2001 From: dcore94 Date: Thu, 18 May 2023 10:09:47 +0200 Subject: [PATCH] relaxed some http reply checks --- ccp/js/executionhistorycontroller.js | 30 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/ccp/js/executionhistorycontroller.js b/ccp/js/executionhistorycontroller.js index 226eb11..c48fae9 100644 --- a/ccp/js/executionhistorycontroller.js +++ b/ccp/js/executionhistorycontroller.js @@ -222,8 +222,8 @@ class CCPExecutionHistory extends HTMLElement { refreshExecution(id){ this.#boot.secureFetch(`${this.#serviceurl}/executions?id=${id}`).then(reply =>{ - if(reply.status === 200) return reply.json(); - else throw `Unable to load execution ${id}` + if(reply.ok) return reply.json(); + else throw `Unable to load execution ${id}. Check console.` }).then(data=>{ //this may occur for timing issues since workflow start is async const exec = data.length === 0 ? { id : id} : data[0] @@ -242,15 +242,15 @@ class CCPExecutionHistory extends HTMLElement { deleteExecution(id){ this.#boot.secureFetch(`${this.#serviceurl}/executions/${id}`, { method: "DELETE"}).then(reply =>{ - if(reply.status === 200) this.refreshExecutions(); - else throw `Unable to delete execution ${id}` + if(reply.ok) this.refreshExecutions(); + else throw `Unable to delete execution ${id}. Check console.` }).catch(err=>{ console.error(err)}) } refreshExecutions(){ this.#boot.secureFetch(`${this.#serviceurl}/executions`).then(reply =>{ - if(reply.status === 200) return reply.json(); - else throw "Unable to load executions" + if(reply.ok) return reply.json(); + else throw "Unable to load executions. Check console." }).then(data=>{ this.#data = data this.updateList() @@ -285,8 +285,8 @@ class CCPExecutionHistory extends HTMLElement { download(url, name) { this.#boot.secureFetch(url).then(reply => { - if (reply.status !== 200) { - throw "Unable to download" + if (!reply.ok) { + throw "Unable to download. Check console." } return reply.blob() @@ -305,7 +305,7 @@ class CCPExecutionHistory extends HTMLElement { export(id, mime, filename){ this.#boot.secureFetch(`${this.#serviceurl}/executions/${id}`, { method: "GET", headers : { "Accept" : mime} }).then(reply =>{ - if (reply.status !== 200) { + if (!reply.ok) { throw "Unable to export " + mime } return reply.blob() @@ -323,8 +323,8 @@ class CCPExecutionHistory extends HTMLElement { reexecute(id,level){ this.#boot.secureFetch(`${this.#serviceurl}/executions/${id}/level/${level}`, { method: "POST" }) .then(reply =>{ - if (reply.status !== 200) { - throw "Unable to re-execute" + if (!reply.ok) { + throw "Unable to re-execute. Check console." } return reply.json() }).then(data=>{ @@ -342,7 +342,7 @@ class CCPExecutionHistory extends HTMLElement { }, formdata) this.#boot.secureFetch(`${this.#serviceurl}/executions`, { body: formdata, method : "POST"}) .then(reply=>{ - if (reply.status !== 200) { + if (!reply.ok) { throw "Unable to import" }else return reply.text() }).then(data=>{ @@ -354,7 +354,7 @@ class CCPExecutionHistory extends HTMLElement { generateCode(id, mime, filename){ this.#boot.secureFetch(`${this.#serviceurl}/executions/${id}/code`, { method: "GET", headers : { "Accept" : mime} }).then(reply =>{ - if (reply.status !== 200) { + if (!reply.ok) { throw "Unable to generate code for " + mime } return reply.blob() @@ -372,7 +372,7 @@ class CCPExecutionHistory extends HTMLElement { toArchive(id){ this.#boot.secureFetch(`${this.#serviceurl}/executions/${id}/archive`, { method: "POST" }) .then(reply =>{ - if (reply.status !== 200) { + if (!reply.ok) { throw "Unable to archive" } }).catch(err=>{ alert(err)}) @@ -382,7 +382,7 @@ class CCPExecutionHistory extends HTMLElement { if(url){ this.#boot.secureFetch(`${this.#serviceurl}/executions/archive?url=${url}`) .then(reply =>{ - if (reply.status !== 200) { + if (!reply.ok) { throw "Unable to fetch from archive" } return reply.text()