refactor: centralize progress reporters, default user-agent, improve error propagation and aria2 fetch usage

This commit is contained in:
Dariusz L
2026-07-02 02:54:38 +02:00
parent f428924ee0
commit 59e61ba077
8 changed files with 50 additions and 100 deletions
+3 -1
View File
@@ -249,7 +249,9 @@ export class ResolverManagerDialog extends ComfyDialog {
errorMsg = errData.error;
}
} catch (_) {}
throw new Error(errorMsg);
const error = new Error(errorMsg);
error.status = response.status;
throw error;
}
if (response.status === 204) {
return null;
+4 -15
View File
@@ -1081,22 +1081,11 @@ export const optionsMethods = {
};
const requestAria2Control = async (endpoint, { method = 'POST', body = {} } = {}) => {
const response = await api.fetchApi(endpoint, {
return this.fetchJson(endpoint, {
method,
headers: { 'Content-Type': 'application/json' },
...(method === 'POST' ? { body: JSON.stringify(body) } : {})
});
if (!response.ok) {
let errorMsg = `Server returned ${response.status}: ${response.statusText}`;
try {
const errData = await response.json();
if (errData?.error) errorMsg = errData.error;
} catch (_) { }
const error = new Error(errorMsg);
error.status = response.status;
throw error;
}
return response.json();
...(method === 'POST' ? { body: JSON.stringify(body) } : {}),
silent: true
}, 'Aria2 Control');
};
const startAria2 = async () => {