{"record":{"id":"9248d94f6740bd00","repo":"linshenkx/prompt-optimizer","slug":"tag-error","errorCode":"TAG_ERROR","errorMessage":"error.message || ''","messagePattern":"error\\.message \\|\\| ''","errorType":"exception","errorClass":"FavoriteTagError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/favorite/electron-proxy.ts","lineNumber":79,"sourceCode":"      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);\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  }","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/favorite/electron-proxy.ts#L61-L97","documentation":"Main process returned TAG_ERROR; converted to FavoriteTagError with code TAG_ERROR and the main-process message. Generic failure of a tag operation that isn't covered by the specific tag codes.","triggerScenarios":"Any tag operation via the proxy where the main process throws an unexpected error while mutating tag storage.","commonSituations":"Storage-level failures during tag writes; partial state after interrupted operation; unexpected data shapes in tag store after migration.","solutions":["Inspect error.message (also preserved in details) for the underlying cause","Check main-process logs around the failing tag operation","Validate/back up the tag store if errors persist","Retry after restarting the app to clear transient locks"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":"const isFavoriteTagError = (e: unknown): e is FavoriteTagError => e instanceof FavoriteTagError;","tryCatchPattern":"try { await mgr.updateTags(...); } catch (e) { if (isFavoriteTagError(e)) { await backoffRetry(once); return; } throw e; }","preventionTips":["Inspect error.details for the underlying cause","Keep tag store backed up","Restart app to clear transient locks before reporting bugs"],"tags":["favorite","tag","storage","electron"],"backgroundTag":"operation-failed-generic","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}