Skip to content

Commit d086360

Browse files
committed
[ns.Update] Перезапрос моделей в случае их невалидности #464
Логи
1 parent 0ff442a commit d086360

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/ns.update.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -401,11 +401,14 @@
401401

402402
// если в моделях есть ошибки или мы превысили лимит перезапусков, то фейлимся
403403
if (modelHasErrors || this._restartCount >= this.RESTART_LIMIT) {
404-
this.log('update has models', this._restartCount, models);
404+
this.log('update has bad models', this._restartCount, models);
405405
// имитируем ошибку "Невалидные модели"
406406
var promise = this._onRequestModelsError(models);
407407
// делаем это синхронно
408408
if (promise.isFulfilled()) {
409+
ns.log.info('ns.Update.error-content', {
410+
_restartCount: this._restartCount
411+
}, models.invalid);
409412
// если ns.Update.handleError решит, что все ок, то запускаем обновление DOM
410413
return this._updateDOM();
411414

@@ -417,6 +420,9 @@
417420
// если модели невалидные, но в них нет ошибок, то пробуем перезапуститься
418421
this._restartCount++;
419422
this.log('restart request models', this._restartCount);
423+
ns.log.info('ns.Update.restart', {
424+
_restartCount: this._restartCount
425+
}, models.invalid);
420426
return this._requestModels(this._models)
421427
.then(this._startUpdateDOM, null, this);
422428
}

src/ns.view.js

+10
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,7 @@
875875
ns.View.prototype._getModelsForTree = function() {
876876
var modelsData = {};
877877

878+
var invalidModels = [];
878879
var models = this.models;
879880
for (var id in models) {
880881
/** @type ns.Model */
@@ -890,9 +891,18 @@
890891
modelsData[id].status = 'error';
891892
// structure for convenient matching
892893
modelsData[id][id] = model.getError();
894+
895+
invalidModels.push(model);
893896
}
894897
}
895898

899+
if (invalidModels.length) {
900+
ns.log.info('ns.View.error-content', {
901+
id: this.id,
902+
key: this.key
903+
}, invalidModels);
904+
}
905+
896906
return modelsData;
897907
};
898908

0 commit comments

Comments
 (0)