linshenkx/prompt-optimizer · error · FavoriteStorageError

Failed to get favorite details: ${errorMessage}

Error message

Failed to get favorite details: ${errorMessage}

What it means

Generic FavoriteStorageError wrapping any unexpected failure that escapes getFavorite's normal flow, most commonly an underlying storage provider error (read failure, corrupted data, serialization issue). The original message is appended for diagnostics.

Source

Thrown at packages/core/src/services/favorite/manager.ts:422

    }
  }

  async getFavorite(id: string): Promise<FavoritePrompt> {
    try {
      const favorites = await this.getFavorites();
      const favorite = favorites.find(f => f.id === id);

      if (!favorite) {
        throw new FavoriteNotFoundError(id);
      }

      return favorite;
    } catch (error) {
      if (error instanceof FavoriteError) {
        throw error;
      }
      const errorMessage = error instanceof Error ? error.message : String(error);
      throw new FavoriteStorageError(`Failed to get favorite details: ${errorMessage}`);
    }
  }

  async updateFavorite(id: string, updates: Partial<FavoritePrompt>): Promise<void> {
    await this.ensureInitialized();

    try {
      if (Object.prototype.hasOwnProperty.call(updates, 'metadata')) {
        assertFavoriteMetadataHasNoInlineImages(updates.metadata);
      }

      await this.storageProvider.updateData(this.STORAGE_KEYS.FAVORITES, (favorites: FavoritePrompt[] | null) => {
        const favoritesList = favorites || [];
        const index = favoritesList.findIndex(f => f.id === id);
        if (index === -1) {
          throw new FavoriteNotFoundError(id);
        }

View on GitHub (pinned to 3e677b1d9f)

Solutions

  1. Inspect the appended errorMessage to identify the storage-layer cause
  2. Verify storage initialization (ensure manager.initialize() completed) before calling getFavorite
  3. Repair or reset the corrupted storage data if the message mentions parse/serialization errors
  4. If transient (file lock, network), retry after the underlying issue clears

Example fix

// before
try { await manager.getFavorite(id); } catch (e) { /* unknown */ }
// after
try { await manager.getFavorite(id); }
catch (e) {
  if (e instanceof FavoriteStorageError) console.error('storage issue:', e.message);
  throw e;
}
Defensive patterns

Strategy: retry

Validate before calling

await manager.getFavorites(); // smoke-test the storage read path first

Try / catch

try { await manager.getFavorite(id); }
catch (e) {
  if (e instanceof FavoriteStorageError) { /* inspect e.message, retry or surface */ }
  else throw e;
}

Prevention

When it happens

Trigger: getFavorites() or the storage provider read fails inside getFavorite with a non-FavoriteError exception: I/O error, quota, corrupted JSON, or an uninitialized provider.

Common situations: Backing store temporarily unavailable (locked file, permissions), corrupted favorites payload after an interrupted write, or a custom storage provider that throws raw errors.

Related errors


AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27). Data as JSON: /api/errors/8766ccae902ce598. Report an issue: GitHub.