{"record":{"id":"a839d8cca04cf0a9","repo":"linshenkx/prompt-optimizer","slug":"failed-to-update-category-errormessage","errorCode":null,"errorMessage":"Failed to update category: ${errorMessage}","messagePattern":"Failed to update category: (.+?)","errorType":"exception","errorClass":"FavoriteStorageError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/favorite/manager.ts","lineNumber":712,"sourceCode":"        const categoriesList = categories || [];\n        const index = categoriesList.findIndex(c => c.id === id);\n        if (index === -1) {\n          throw new FavoriteCategoryNotFoundError(id);\n        }\n\n        categoriesList[index] = {\n          ...categoriesList[index],\n          ...updates\n        };\n\n        return categoriesList;\n      });\n    } catch (error) {\n      if (error instanceof FavoriteError) {\n        throw error;\n      }\n      const errorMessage = error instanceof Error ? error.message : String(error);\n      throw new FavoriteStorageError(`Failed to update category: ${errorMessage}`);\n    }\n  }\n\n  /**\n   * 删除分类\n   * 会自动清空该分类下所有收藏的分类字段\n   *\n   * @param id 分类ID\n   * @returns 受影响的收藏数量\n   */\n  async deleteCategory(id: string): Promise<number> {\n    await this.ensureInitialized();\n\n    try {\n      // ✅ 获取该分类下的所有收藏\n      const allFavorites = await this.getFavorites();\n      const favoritesInCategory = allFavorites.filter(f => f.category === id);\n","sourceCodeStart":694,"sourceCodeEnd":730,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/favorite/manager.ts#L694-L730","documentation":"Generic storage wrapper thrown by updateCategory when the storage operation fails for a reason other than a known FavoriteError. It wraps the original error message (and preserves non-Favorite errors only if they aren't FavoriteError instances).","triggerScenarios":"storageProvider.updateData throws a raw Error (quota, I/O, serialization) while renaming or recategorizing; the update callback mutates data in a way the provider cannot serialize.","commonSituations":"Storage quota exceeded during updates; custom storage provider bugs; transient IndexedDB/async-storage failures on mobile.","solutions":["Read the embedded errorMessage to find the underlying cause","Retry once for transient provider failures","Check storage availability/quota before performing updates","Validate updates payload is serializable (no functions/cycles)"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":"const isFavoriteStorageError = (e: unknown): e is FavoriteStorageError => e instanceof FavoriteStorageError;","tryCatchPattern":"try { await manager.updateCategory(id, updates); } catch (e) { if (isFavoriteStorageError(e) && isTransient(e.cause)) { await retry(() => manager.updateCategory(id, updates), 1); } else throw e; }","preventionTips":["Keep updates payloads small and serializable","Handle transient storage failures with a single retry"],"tags":["storage","io","favorites","update"],"backgroundTag":"storage-write-failed","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}