linshenkx/prompt-optimizer · critical · FavoriteMigrationError

error.message || ''

Error message

error.message || ''

What it means

Main process returned MIGRATION_ERROR; converted to FavoriteMigrationError with the message and cause. The favorites store schema/data migration in the main process failed.

Source

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

        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);
      }
      if (error.code === 'IMPORT_EXPORT_ERROR') {
        throw new FavoriteImportExportError(error.message || '', error.cause, error.details);
      }
      // Fallback: preserve message as details for i18n-friendly error
      throw new FavoriteError(FAVORITE_ERROR_CODES.STORAGE_ERROR, error.message || 'Unknown error', {
        details: error.message || 'Unknown error',
      });
    }
  }

  async addFavorite(favorite: Omit<FavoritePrompt, 'id' | 'createdAt' | 'updatedAt' | 'useCount'>): Promise<string> {
    return this.invokeMethod('addFavorite', favorite);
  }

  async getFavorites(options?: {
    categoryId?: string;
    tags?: string[];

View on GitHub (pinned to 3e677b1d9f)

Solutions

  1. Back up the favorites store file (in userData) immediately
  2. Check the migration step that failed in main-process logs (cause is preserved)
  3. Restore from backup or export and re-import favorites into a fresh store
  4. Report the issue with store schema version if migration is genuinely buggy
Defensive patterns

Strategy: fallback

Type guard

const isMigrationError = (e: unknown): e is FavoriteMigrationError => e instanceof FavoriteMigrationError;

Try / catch

try { await mgr.getFavorites(); } catch (e) { if (isMigrationError(e)) { offerRestoreFromBackup(); return; } throw e; }

Prevention

When it happens

Trigger: App startup or first favorite operation triggers a store migration (schema version bump) that throws; the proxy rethrows FavoriteMigrationError.

Common situations: Upgrading the app across schema versions with an old/corrupted store; partially completed previous migration; manual edits to the store file; version downgrade then upgrade.

Related errors


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