linshenkx/prompt-optimizer · error · FavoriteTagError

TAG_ERROR

TAG_ERROR

Error message

error.message || ''

What it means

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.

Source

Thrown at packages/core/src/services/favorite/electron-proxy.ts:79

      if (error.code === 'VALIDATION_ERROR') {
        throw new FavoriteValidationError(error.message || '');
      }
      if (error.code === 'STORAGE_ERROR') {
        throw new FavoriteStorageError(error.message || '');
      }
      // Legacy: category already exists
      if (error.code === 'CATEGORY_ALREADY_EXISTS') {
        throw new FavoriteValidationError(error.message || 'Category already exists')
      }
      // 标签相关错误
      if (error.code === 'TAG_ALREADY_EXISTS') {
        throw new FavoriteTagAlreadyExistsError(error.tag || '');
      }
      if (error.code === 'TAG_NOT_FOUND') {
        throw new FavoriteTagNotFoundError(error.tag || '');
      }
      if (error.code === 'TAG_ERROR') {
        throw new FavoriteTagError(FAVORITE_ERROR_CODES.TAG_ERROR, error.message || '', { details: error.message || '' });
      }
      // 数据迁移和导入导出错误
      if (error.code === 'MIGRATION_ERROR') {
        throw new FavoriteMigrationError(error.message || '', error.cause);
      }
      if (error.code === 'IMPORT_EXPORT_ERROR') {
        throw new FavoriteImportExportError(error.message || '', error.cause, error.details);
      }
      // Fallback: preserve message as details for i18n-friendly error
      throw new FavoriteError(FAVORITE_ERROR_CODES.STORAGE_ERROR, error.message || 'Unknown error', {
        details: error.message || 'Unknown error',
      });
    }
  }

  async addFavorite(favorite: Omit<FavoritePrompt, 'id' | 'createdAt' | 'updatedAt' | 'useCount'>): Promise<string> {
    return this.invokeMethod('addFavorite', favorite);
  }

View on GitHub (pinned to 3e677b1d9f)

Solutions

  1. Inspect error.message (also preserved in details) for the underlying cause
  2. Check main-process logs around the failing tag operation
  3. Validate/back up the tag store if errors persist
  4. Retry after restarting the app to clear transient locks
Defensive patterns

Strategy: retry

Type guard

const isFavoriteTagError = (e: unknown): e is FavoriteTagError => e instanceof FavoriteTagError;

Try / catch

try { await mgr.updateTags(...); } catch (e) { if (isFavoriteTagError(e)) { await backoffRetry(once); return; } throw e; }

Prevention

When it happens

Trigger: Any tag operation via the proxy where the main process throws an unexpected error while mutating tag storage.

Common situations: Storage-level failures during tag writes; partial state after interrupted operation; unexpected data shapes in tag store after migration.

Related errors


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