improve filters error handling

This commit is contained in:
buzzcode2007 2024-04-03 10:15:14 +08:00
parent 1ce691bec6
commit cd788b8e32

View file

@ -108,30 +108,19 @@ export default class filters {
);
// Create promise of downloading.
let filter_download = net.download(filter_URL, `JSON`);
let filter_download = net.download(filter_URL, `JSON`, false, true);
filter_download
.then((result) => {
// Only work when the filter is valid.
if (result) {
// Write the filter to storage.
secretariat.write(["filters", filter_URL], result, -1);
alerts.log(
texts.localized(
`settings_filters_update_status_complete`,
null,
[filter_URL],
),
);
alerts.log(texts.localized(`settings_filters_update_status_complete`,null,[filter_URL]));
}
})
.catch((error) => {
// Inform the user of the download failure.
alerts.error(
texts.localized(`settings_filters_update_status_failure`, null, [
error,
filter_URL,
]),
);
alerts.error(error.name, texts.localized(`settings_filters_update_status_failure`, null, [error.name, filter_URL]), error.stack);
});
}
} else {