{"record":{"id":"f150a14bb7de15cd","repo":"linshenkx/prompt-optimizer","slug":"storage-error","errorCode":"STORAGE_ERROR","errorMessage":"${error.message}","messagePattern":"\\$\\{error\\.message\\}","errorType":"exception","errorClass":"FavoriteStorageError","httpStatus":null,"severity":"critical","filePath":"packages/core/src/services/favorite/electron-proxy.ts","lineNumber":65,"sourceCode":"      if (typeof error?.code === 'string' && error.code.startsWith('error.')) {\n        throw toErrorWithCode(error)\n      }\n\n      // 将IPC错误转换为具体的错误类型\n      if (error.code === 'FAVORITE_NOT_FOUND') {\n        throw new FavoriteNotFoundError(error.id || '');\n      }\n      if (error.code === 'FAVORITE_ALREADY_EXISTS') {\n        throw new FavoriteAlreadyExistsError(error.content || '');\n      }\n      if (error.code === 'CATEGORY_NOT_FOUND') {\n        throw new FavoriteCategoryNotFoundError(error.id || '');\n      }\n      if (error.code === 'VALIDATION_ERROR') {\n        throw new FavoriteValidationError(error.message || '');\n      }\n      if (error.code === 'STORAGE_ERROR') {\n        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);","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/favorite/electron-proxy.ts#L47-L83","documentation":"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.","triggerScenarios":"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.","commonSituations":"Store file corrupted after crash; antivirus/permissions blocking the userData dir; disk full; concurrent Electron instances locking storage.","solutions":["Check the main-process log for the underlying storage error","Restore or delete the corrupted store file (it is usually under userData) to let the app recreate it","Verify write permissions and disk space for the userData directory","Export/back up favorites before resetting storage"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":"const isFavoriteStorageError = (e: unknown): e is FavoriteStorageError => e instanceof FavoriteStorageError;","tryCatchPattern":"try { await mgr.getFavorites(); } catch (e) { if (isFavoriteStorageError(e)) { return cachedFavorites ?? []; } throw e; }","preventionTips":["Back up the favorites store regularly","Watch for I/O errors in main-process logs","Avoid running two instances writing the same store"],"tags":["favorite","storage","io","electron"],"backgroundTag":"persistent-storage-corruption","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}