1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-28 05:03:59 +03:00

pass lazy loading flag into error, to format message based on it

This commit is contained in:
Bruno Windels
2018-09-26 16:12:30 +01:00
parent 78a5a88638
commit 2d5eb920b8
2 changed files with 3 additions and 2 deletions

View File

@@ -3120,7 +3120,7 @@ MatrixClient.prototype.startClient = async function(opts) {
const shouldClear = await this._wasLazyLoadingToggled(opts.lazyLoadMembers); const shouldClear = await this._wasLazyLoadingToggled(opts.lazyLoadMembers);
if (shouldClear) { if (shouldClear) {
const reason = InvalidStoreError.TOGGLED_LAZY_LOADING; const reason = InvalidStoreError.TOGGLED_LAZY_LOADING;
throw new InvalidStoreError(reason); throw new InvalidStoreError(reason, !!opts.lazyLoadMembers);
} }
if (opts.lazyLoadMembers && this._crypto) { if (opts.lazyLoadMembers && this._crypto) {
this._crypto.enableLazyLoading(); this._crypto.enableLazyLoading();

View File

@@ -1,11 +1,12 @@
// can't just do InvalidStoreError extends Error // can't just do InvalidStoreError extends Error
// because of http://babeljs.io/docs/usage/caveats/#classes // because of http://babeljs.io/docs/usage/caveats/#classes
function InvalidStoreError(reason) { function InvalidStoreError(reason, value) {
const message = `Store is invalid because ${reason}, ` + const message = `Store is invalid because ${reason}, ` +
`please delete all data and retry`; `please delete all data and retry`;
const instance = Reflect.construct(Error, [message]); const instance = Reflect.construct(Error, [message]);
Reflect.setPrototypeOf(instance, Reflect.getPrototypeOf(this)); Reflect.setPrototypeOf(instance, Reflect.getPrototypeOf(this));
instance.reason = reason; instance.reason = reason;
instance.value = value;
return instance; return instance;
} }