linshenkx/prompt-optimizer · error · FavoriteStorageError
Failed to update category: ${errorMessage}
Error message
Failed to update category: ${errorMessage} What it means
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).
Source
Thrown at packages/core/src/services/favorite/manager.ts:712
const categoriesList = categories || [];
const index = categoriesList.findIndex(c => c.id === id);
if (index === -1) {
throw new FavoriteCategoryNotFoundError(id);
}
categoriesList[index] = {
...categoriesList[index],
...updates
};
return categoriesList;
});
} catch (error) {
if (error instanceof FavoriteError) {
throw error;
}
const errorMessage = error instanceof Error ? error.message : String(error);
throw new FavoriteStorageError(`Failed to update category: ${errorMessage}`);
}
}
/**
* 删除分类
* 会自动清空该分类下所有收藏的分类字段
*
* @param id 分类ID
* @returns 受影响的收藏数量
*/
async deleteCategory(id: string): Promise<number> {
await this.ensureInitialized();
try {
// ✅ 获取该分类下的所有收藏
const allFavorites = await this.getFavorites();
const favoritesInCategory = allFavorites.filter(f => f.category === id);
View on GitHub (pinned to 3e677b1d9f)
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)
Defensive patterns
Strategy: retry
Type guard
const isFavoriteStorageError = (e: unknown): e is FavoriteStorageError => e instanceof FavoriteStorageError;
Try / catch
try { await manager.updateCategory(id, updates); } catch (e) { if (isFavoriteStorageError(e) && isTransient(e.cause)) { await retry(() => manager.updateCategory(id, updates), 1); } else throw e; } Prevention
- Keep updates payloads small and serializable
- Handle transient storage failures with a single retry
When it happens
Trigger: 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.
Common situations: Storage quota exceeded during updates; custom storage provider bugs; transient IndexedDB/async-storage failures on mobile.
Related errors
- Failed to add category: ${errorMessage}
- Failed to delete category: ${errorMessage}
- STORAGE_ERROR
- Failed to add favorite: ${errorMessage}
- Failed to get favorite details: ${errorMessage}
AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27).
Data as JSON: /api/errors/a839d8cca04cf0a9.
Report an issue: GitHub.