backend API to create a launcher

This commit is contained in:
zadam
2022-12-22 14:57:00 +01:00
parent 059c339c09
commit 8ec2547b4a
32 changed files with 947 additions and 173 deletions

View File

@@ -105,21 +105,23 @@ async function call(method, url, data, headers = {}) {
async function reportError(method, url, statusCode, response) {
const toastService = (await import("./toast.js")).default;
let message = response;
if (typeof response === 'string') {
try {
response = JSON.parse(response);
message = response.message;
}
catch (e) { throw e;}
catch (e) {}
}
if ([400, 404].includes(statusCode) && response && typeof response === 'object') {
toastService.showError(response.message);
toastService.showError(message);
throw new ValidationError(response);
} else {
const message = `Error when calling ${method} ${url}: ${statusCode} - ${response}`;
toastService.showError(message);
toastService.throwError(message);
const title = `${statusCode} ${method} ${url}`;
toastService.showErrorTitleAndMessage(title, message);
toastService.throwError(`${title} - ${message}`);
}
}