linshenkx/prompt-optimizer · error · FavoriteStorageError

Failed to add tag: ${errorMessage}

Error message

Failed to add tag: ${errorMessage}

What it means

FavoriteStorageError wrapper thrown by addTag when the tag-library update fails for a non-FavoriteError reason. The original error is preserved as cause.

Source

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

        const newTag: FavoriteTag = {
          tag: trimmedTag,
          createdAt: now
        };

        added = true;
        return [...tagsList, newTag];
      });

      // 仅在新增标签时更新统计信息
      if (added) {
        await this.updateStats();
      }
    } catch (error) {
      if (error instanceof FavoriteError) {
        throw error;
      }
      const errorMessage = error instanceof Error ? error.message : String(error);
      throw new FavoriteStorageError(
        `Failed to add tag: ${errorMessage}`,
        error instanceof Error ? error : undefined
      );
    }
  }

  async renameTag(oldTag: string, newTag: string): Promise<number> {
    if (!oldTag || !newTag) {
      throw new FavoriteValidationError('Tag name cannot be empty');
    }

    if (oldTag === newTag) {
      return 0; // 无需操作
    }

    let affectedCount = 0;
    let oldTagExistedInIndependentLib = false;

View on GitHub (pinned to 3e677b1d9f)

Solutions

  1. Read error.cause for the root failure
  2. Free storage space / prune unused tags
  3. Retry once for transient provider errors
Defensive patterns

Strategy: retry

Type guard

const isFavoriteStorageError = (e: unknown): e is FavoriteStorageError => e instanceof FavoriteStorageError;

Try / catch

try { await manager.addTag(t); } catch (e) { if (isFavoriteStorageError(e) && isTransient(e.cause)) await manager.addTag(t); else throw e; }

Prevention

When it happens

Trigger: storageProvider.updateData(TAGS, ...) throwing quota/I/O/serialization errors while inserting a new tag.

Common situations: Storage quota exhausted from many tags; provider write failures; concurrent tag writes colliding.

Related errors


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