How to use the dexie.errnames function in dexie

To help you get started, we’ve selected a few dexie examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ONEARMY / community-platform / src / stores / databaseV2 / clients / dexie.tsx View on Github external
db.open().catch(async err => {
      console.error(err)
      // NOTE - invalid state error suggests dexie not supported, so
      // try reloading with cachedb disabled (see db index for implementation)
      if (err.name === Dexie.errnames.InvalidState) {
        if (err.inner.name === Dexie.errnames.InvalidState) {
          location.replace(location.href + '?no-cache')
        }
      }
      // NOTE - upgrade error can be avoided by defining legacy db caches
      // with corresponding upgrade functions (see below method TODO)
      if (err.name === Dexie.errnames.Upgrade) {
        await Dexie.delete(CACHE_DB_NAME).catch(() => location.reload())
        return location.reload()
      }
    })
  }
github ONEARMY / community-platform / src / stores / databaseV2 / clients / dexie.tsx View on Github external
db.open().catch(async err => {
      console.error(err)
      // NOTE - invalid state error suggests dexie not supported, so
      // try reloading with cachedb disabled (see db index for implementation)
      if (err.name === Dexie.errnames.InvalidState) {
        if (err.inner.name === Dexie.errnames.InvalidState) {
          location.replace(location.href + '?no-cache')
        }
      }
      // NOTE - upgrade error can be avoided by defining legacy db caches
      // with corresponding upgrade functions (see below method TODO)
      if (err.name === Dexie.errnames.Upgrade) {
        await Dexie.delete(CACHE_DB_NAME).catch(() => location.reload())
        return location.reload()
      }
    })
  }
github fossar / selfoss / assets / js / selfoss-db.js View on Github external
promise.catch(function(error) {
            selfoss.ui.showError(selfoss.ui._('error_offline_storage', [error.message]));
            selfoss.db.storage = null;
            selfoss.db.reloadList();

            // If this is a QuotaExceededError, garbage collect more
            // entries and hope it helps.
            if (error.name === Dexie.errnames.QuotaExceeded) {
                selfoss.dbOffline.GCEntries(true);
            }

            throw error;
        });
github WorldBrain / Memex / src / search / storage / index.ts View on Github external
export const initErrHandler = (defReturnVal: T = null) => (
    err: Dexie.DexieError,
) => {
    if (
        err.message === 'Data fetch failed' ||
        (err.name === Dexie.errnames.OpenFailed &&
            err.message.includes('createObjectStore'))
    ) {
        return defReturnVal
    }

    throw err
}
github wireapp / wire-web-packages / packages / store-engine-dexie / src / index.ts View on Github external
private mapDatabaseError(
    error: Dexie.DexieError,
    tableName: string,
    primaryKey: PrimaryKey,
  ): Error {
    const isAlreadyExisting = error instanceof Dexie.ConstraintError;
    /** @see https://github.com/dfahlander/Dexie.js/issues/776 */
    const hasNotEnoughDiskSpace =
      error.name === Dexie.errnames.QuotaExceeded || error.inner?.name === Dexie.errnames.QuotaExceeded;

    if (isAlreadyExisting) {
      const message = `Record "${primaryKey}" already exists in "${tableName}". You need to delete the record first if you want to overwrite it.`;
      return new StoreEngineError.RecordAlreadyExistsError(message);
    } else if (hasNotEnoughDiskSpace) {
      const message = `Cannot save "${primaryKey}" in "${tableName}" because there is low disk space.`;
      return new StoreEngineError.LowDiskSpaceError(message);
    } else {
      return error;
    }
  }
github wireapp / wire-web-packages / packages / store-engine-dexie / src / index.ts View on Github external
private mapDatabaseError(error: Dexie.DexieError, tableName: string, primaryKey: string): Error {
    const isAlreadyExisting = error instanceof Dexie.ConstraintError;
    /** @see https://github.com/dfahlander/Dexie.js/issues/776 */
    const hasNotEnoughDiskSpace =
      error.name === Dexie.errnames.QuotaExceeded || (error.inner && error.inner.name === Dexie.errnames.QuotaExceeded);

    if (isAlreadyExisting) {
      const message = `Record "${primaryKey}" already exists in "${tableName}". You need to delete the record first if you want to overwrite it.`;
      return new StoreEngineError.RecordAlreadyExistsError(message);
    } else if (hasNotEnoughDiskSpace) {
      const message = `Cannot save "${primaryKey}" in "${tableName}" because there is low disk space.`;
      return new StoreEngineError.LowDiskSpaceError(message);
    } else {
      return error;
    }
  }
}