linshenkx/prompt-optimizer · critical · FavoriteStorageError

STORAGE_ERROR

STORAGE_ERROR

Error message

${error.message}

What it means

Main process returned STORAGE_ERROR; converted to FavoriteStorageError with the underlying message. The persistent storage backing favorites (files/DB in the Electron main process) failed.

Source

Thrown at packages/core/src/services/favorite/electron-proxy.ts:65

      if (typeof error?.code === 'string' && error.code.startsWith('error.')) {
        throw toErrorWithCode(error)
      }

      // 将IPC错误转换为具体的错误类型
      if (error.code === 'FAVORITE_NOT_FOUND') {
        throw new FavoriteNotFoundError(error.id || '');
      }
      if (error.code === 'FAVORITE_ALREADY_EXISTS') {
        throw new FavoriteAlreadyExistsError(error.content || '');
      }
      if (error.code === 'CATEGORY_NOT_FOUND') {
        throw new FavoriteCategoryNotFoundError(error.id || '');
      }
      if (error.code === 'VALIDATION_ERROR') {
        throw new FavoriteValidationError(error.message || '');
      }
      if (error.code === 'STORAGE_ERROR') {
        throw new FavoriteStorageError(error.message || '');
      }
      // Legacy: category already exists
      if (error.code === 'CATEGORY_ALREADY_EXISTS') {
        throw new FavoriteValidationError(error.message || 'Category already exists')
      }
      // 标签相关错误
      if (error.code === 'TAG_ALREADY_EXISTS') {
        throw new FavoriteTagAlreadyExistsError(error.tag || '');
      }
      if (error.code === 'TAG_NOT_FOUND') {
        throw new FavoriteTagNotFoundError(error.tag || '');
      }
      if (error.code === 'TAG_ERROR') {
        throw new FavoriteTagError(FAVORITE_ERROR_CODES.TAG_ERROR, error.message || '', { details: error.message || '' });
      }
      // 数据迁移和导入导出错误
      if (error.code === 'MIGRATION_ERROR') {
        throw new FavoriteMigrationError(error.message || '', error.cause);

View on GitHub (pinned to 3e677b1d9f)

Solutions

  1. Check the main-process log for the underlying storage error
  2. Restore or delete the corrupted store file (it is usually under userData) to let the app recreate it
  3. Verify write permissions and disk space for the userData directory
  4. Export/back up favorites before resetting storage
Defensive patterns

Strategy: fallback

Type guard

const isFavoriteStorageError = (e: unknown): e is FavoriteStorageError => e instanceof FavoriteStorageError;

Try / catch

try { await mgr.getFavorites(); } catch (e) { if (isFavoriteStorageError(e)) { return cachedFavorites ?? []; } throw e; }

Prevention

When it happens

Trigger: Any proxy call when the main process cannot read/write its favorites store: disk I/O error, corrupted store file, locked file, or failed migration.

Common situations: Store file corrupted after crash; antivirus/permissions blocking the userData dir; disk full; concurrent Electron instances locking storage.

Related errors


AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27). Data as JSON: /api/errors/f150a14bb7de15cd. Report an issue: GitHub.