{"record":{"id":"4adb706572427d77","repo":"linshenkx/prompt-optimizer","slug":"error-message","errorCode":null,"errorMessage":"error.message || ''","messagePattern":"error\\.message \\|\\| ''","errorType":"exception","errorClass":"FavoriteMigrationError","httpStatus":null,"severity":"critical","filePath":"packages/core/src/services/favorite/electron-proxy.ts","lineNumber":83,"sourceCode":"        throw new FavoriteStorageError(error.message || '');\n      }\n      // Legacy: category already exists\n      if (error.code === 'CATEGORY_ALREADY_EXISTS') {\n        throw new FavoriteValidationError(error.message || 'Category already exists')\n      }\n      // 标签相关错误\n      if (error.code === 'TAG_ALREADY_EXISTS') {\n        throw new FavoriteTagAlreadyExistsError(error.tag || '');\n      }\n      if (error.code === 'TAG_NOT_FOUND') {\n        throw new FavoriteTagNotFoundError(error.tag || '');\n      }\n      if (error.code === 'TAG_ERROR') {\n        throw new FavoriteTagError(FAVORITE_ERROR_CODES.TAG_ERROR, error.message || '', { details: error.message || '' });\n      }\n      // 数据迁移和导入导出错误\n      if (error.code === 'MIGRATION_ERROR') {\n        throw new FavoriteMigrationError(error.message || '', error.cause);\n      }\n      if (error.code === 'IMPORT_EXPORT_ERROR') {\n        throw new FavoriteImportExportError(error.message || '', error.cause, error.details);\n      }\n      // Fallback: preserve message as details for i18n-friendly error\n      throw new FavoriteError(FAVORITE_ERROR_CODES.STORAGE_ERROR, error.message || 'Unknown error', {\n        details: error.message || 'Unknown error',\n      });\n    }\n  }\n\n  async addFavorite(favorite: Omit<FavoritePrompt, 'id' | 'createdAt' | 'updatedAt' | 'useCount'>): Promise<string> {\n    return this.invokeMethod('addFavorite', favorite);\n  }\n\n  async getFavorites(options?: {\n    categoryId?: string;\n    tags?: string[];","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/favorite/electron-proxy.ts#L65-L101","documentation":"Main process returned MIGRATION_ERROR; converted to FavoriteMigrationError with the message and cause. The favorites store schema/data migration in the main process failed.","triggerScenarios":"App startup or first favorite operation triggers a store migration (schema version bump) that throws; the proxy rethrows FavoriteMigrationError.","commonSituations":"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.","solutions":["Back up the favorites store file (in userData) immediately","Check the migration step that failed in main-process logs (cause is preserved)","Restore from backup or export and re-import favorites into a fresh store","Report the issue with store schema version if migration is genuinely buggy"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":"const isMigrationError = (e: unknown): e is FavoriteMigrationError => e instanceof FavoriteMigrationError;","tryCatchPattern":"try { await mgr.getFavorites(); } catch (e) { if (isMigrationError(e)) { offerRestoreFromBackup(); return; } throw e; }","preventionTips":["Back up the favorites store before upgrading the app","Never hand-edit the store file","Keep export snapshots for disaster recovery"],"tags":["favorite","migration","storage","upgrade"],"backgroundTag":"schema-migration-failed","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}