mirror of
https://github.com/zadam/trilium.git
synced 2025-11-05 04:45:47 +01:00
backend API to create a launcher
This commit is contained in:
@@ -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}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user