gamma-common-errors

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Gamma Common Errors

Gamma常见错误

Overview

概述

Reference guide for debugging and resolving common Gamma API errors.
这是一份用于调试和解决常见Gamma API错误的参考指南。

Prerequisites

前提条件

  • Active Gamma integration
  • Access to logs and error messages
  • Understanding of HTTP status codes
  • 已激活Gamma集成
  • 可访问日志和错误信息
  • 理解HTTP状态码

Error Reference

错误参考

Authentication Errors (401/403)

认证错误(401/403)

typescript
// Error: Invalid API Key
{
  "error": "unauthorized",
  "message": "Invalid or expired API key"
}
Solutions:
  1. Verify API key in Gamma dashboard
  2. Check environment variable is set:
    echo $GAMMA_API_KEY
  3. Ensure key hasn't been rotated
  4. Check for trailing whitespace in key
typescript
// Error: Invalid API Key
{
  "error": "unauthorized",
  "message": "Invalid or expired API key"
}
解决方案:
  1. 在Gamma控制台验证API密钥
  2. 检查环境变量是否设置:
    echo $GAMMA_API_KEY
  3. 确保密钥未被轮换
  4. 检查密钥是否存在尾随空格

Rate Limit Errors (429)

速率限制错误(429)

typescript
// Error: Rate Limited
{
  "error": "rate_limited",
  "message": "Too many requests",
  "retry_after": 60
}
Solutions:
  1. Implement exponential backoff
  2. Check rate limit headers:
    X-RateLimit-Remaining
  3. Upgrade plan for higher limits
  4. Queue requests with delays
typescript
async function withRetry(fn: () => Promise<any>, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    try {
      return await fn();
    } catch (err) {
      if (err.code === 'rate_limited' && i < maxRetries - 1) {
        const delay = (err.retryAfter || Math.pow(2, i)) * 1000;
        await new Promise(r => setTimeout(r, delay));
        continue;
      }
      throw err;
    }
  }
}
typescript
// Error: Rate Limited
{
  "error": "rate_limited",
  "message": "Too many requests",
  "retry_after": 60
}
解决方案:
  1. 实现指数退避机制
  2. 检查速率限制响应头:
    X-RateLimit-Remaining
  3. 升级套餐以获得更高限制
  4. 对请求进行延迟排队
typescript
async function withRetry(fn: () => Promise<any>, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    try {
      return await fn();
    } catch (err) {
      if (err.code === 'rate_limited' && i < maxRetries - 1) {
        const delay = (err.retryAfter || Math.pow(2, i)) * 1000;
        await new Promise(r => setTimeout(r, delay));
        continue;
      }
      throw err;
    }
  }
}

Generation Errors (400/500)

生成错误(400/500)

typescript
// Error: Generation Failed
{
  "error": "generation_failed",
  "message": "Unable to generate presentation",
  "details": "Content too complex"
}
Solutions:
  1. Simplify prompt or reduce slide count
  2. Remove special characters from content
  3. Check content length limits
  4. Try different style setting
typescript
// Error: Generation Failed
{
  "error": "generation_failed",
  "message": "Unable to generate presentation",
  "details": "Content too complex"
}
解决方案:
  1. 简化提示词或减少幻灯片数量
  2. 移除内容中的特殊字符
  3. 检查内容长度限制
  4. 尝试不同的样式设置

Timeout Errors

超时错误

typescript
// Error: Request Timeout
{
  "error": "timeout",
  "message": "Request timed out after 30000ms"
}
Solutions:
  1. Increase client timeout setting
  2. Use async job pattern for large presentations
  3. Check network connectivity
  4. Reduce request complexity
typescript
const gamma = new GammaClient({
  apiKey: process.env.GAMMA_API_KEY,
  timeout: 60000, // 60 seconds
});
typescript
// Error: Request Timeout
{
  "error": "timeout",
  "message": "Request timed out after 30000ms"
}
解决方案:
  1. 增加客户端超时设置
  2. 对大型演示文稿使用异步任务模式
  3. 检查网络连接情况
  4. 降低请求复杂度
typescript
const gamma = new GammaClient({
  apiKey: process.env.GAMMA_API_KEY,
  timeout: 60000, // 60 seconds
});

Export Errors

导出错误

typescript
// Error: Export Failed
{
  "error": "export_failed",
  "message": "Unable to export presentation",
  "format": "pdf"
}
Solutions:
  1. Verify presentation exists and is complete
  2. Check supported export formats
  3. Ensure no pending generation jobs
  4. Try exporting with lower quality setting
typescript
// Error: Export Failed
{
  "error": "export_failed",
  "message": "Unable to export presentation",
  "format": "pdf"
}
解决方案:
  1. 验证演示文稿是否存在且已完成
  2. 检查支持的导出格式
  3. 确保没有待处理的生成任务
  4. 尝试使用较低质量设置导出

Debugging Tools

调试工具

Enable Debug Logging

启用调试日志

typescript
const gamma = new GammaClient({
  apiKey: process.env.GAMMA_API_KEY,
  debug: true, // Logs all requests/responses
});
typescript
const gamma = new GammaClient({
  apiKey: process.env.GAMMA_API_KEY,
  debug: true, // Logs all requests/responses
});

Check API Status

检查API状态

typescript
const status = await gamma.status();
console.log('API Status:', status.healthy ? 'OK' : 'Issues');
console.log('Services:', status.services);
typescript
const status = await gamma.status();
console.log('API Status:', status.healthy ? 'OK' : 'Issues');
console.log('Services:', status.services);

Error Handling Pattern

错误处理模式

typescript
import { GammaError, RateLimitError, AuthError } from '@gamma/sdk';

try {
  const result = await gamma.presentations.create({ ... });
} catch (err) {
  if (err instanceof AuthError) {
    console.error('Check your API key');
  } else if (err instanceof RateLimitError) {
    console.error(`Retry after ${err.retryAfter}s`);
  } else if (err instanceof GammaError) {
    console.error('API Error:', err.message);
  } else {
    throw err;
  }
}
typescript
import { GammaError, RateLimitError, AuthError } from '@gamma/sdk';

try {
  const result = await gamma.presentations.create({ ... });
} catch (err) {
  if (err instanceof AuthError) {
    console.error('Check your API key');
  } else if (err instanceof RateLimitError) {
    console.error(`Retry after ${err.retryAfter}s`);
  } else if (err instanceof GammaError) {
    console.error('API Error:', err.message);
  } else {
    throw err;
  }
}

Resources

资源

Next Steps

下一步操作

Proceed to
gamma-debug-bundle
for comprehensive debugging tools.
前往
gamma-debug-bundle
获取全面的调试工具。