Set response ErrorCode as iError for easier fetch error handling

This commit is contained in:
djmaze 2021-03-18 12:33:13 +01:00
parent a46c0c3b21
commit 11fd6736bb
24 changed files with 145 additions and 253 deletions

View file

@ -1,6 +1,5 @@
import ko from 'ko';
import { Notification } from 'Common/Enums';
import { getNotification, i18nToNodes } from 'Common/Translator';
import { addObservablesTo } from 'Common/Utils';
import { delegateRunOnDestroy } from 'Common/UtilsUser';
@ -61,16 +60,13 @@ class SieveScriptPopupView extends AbstractViewPopup {
(iError, data) => {
self.saving = false;
if (!iError && data && data.Result) {
if (iError) {
self.saveError(true);
self.saveErrorText((data && data.ErrorMessageAdditional) || getNotification(iError));
} else {
script.exists() || SieveUserStore.scripts.push(script);
script.exists(true);
script.hasChanges(false);
} else {
self.saveError(true);
self.saveErrorText((data && data.ErrorCode)
? (data.ErrorMessageAdditional || getNotification(data.ErrorCode))
: getNotification(Notification.CantSaveFilters)
);
}
},
script