Skip to content

Commit

Permalink
Add calling errorHandler for load in "raw" mode in customStore (T1225…
Browse files Browse the repository at this point in the history
  • Loading branch information
GoodDayForSurf authored Apr 15, 2024
1 parent ef2ac17 commit b5252b3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/devextreme/js/data/custom_store.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,12 @@ function runRawLoad(pendingDeferred, store, userFuncOptions, continuation) {
}
continuation(rawData);
})
.fail(createUserFuncFailureHandler(pendingDeferred));
.fail((error) => {
const userFuncFailureHandler = createUserFuncFailureHandler(pendingDeferred);

store._errorHandler?.(error);
userFuncFailureHandler(error);
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,28 @@ QUnit.module('load', function() {
}, done, assert);
});

QUnit.test('call errorHandler if load throw error', function(assert) {
const done = assert.async();
let errorHandlerCallsCount = 0;
let errorMessage = null;

new CustomStore({
loadMode: RAW,
async load() {
throw Error('expected error');
},
errorHandler() {
++errorHandlerCallsCount;
}
}).load().fail((error) => {
errorMessage = error.message;
}).always(() => {
assert.equal(errorHandlerCallsCount, 1, 'errorHandler must be called 1 time');
assert.equal(errorMessage, 'expected error', 'error is equal to expected');
done();
});
});

});

QUnit.module('totalCount', function() {
Expand Down

0 comments on commit b5252b3

Please sign in to comment.