类:SpringAIErrorMapper

java.lang.Object
com.google.adk.models.springai.error.SpringAIErrorMapper

public class SpringAIErrorMapper extends Object
将 Spring AI 抛出的异常映射到相应的 ADK 异常,并采用相应的错误处理策略。

该类提供了以下功能:

  • 异常分类与映射
  • 关于重试策略的建议
  • 错误信息的标准化处理
  • 速率限制检测(Rate Limiting Detection)
  • 构造函数详细信息

    • SpringAIErrorMapper

      public SpringAIErrorMapper()
  • 方法详细信息(Method Details)

    • mapError

      public static SpringAIErrorMapper.MappedError mapError(Throwable exception)
      将 Spring AI 异常映射到相应的错误类别和重试策略。
      Parameters:
      exception - the Spring AI exception
      Returns:
      mapped error information
    • isRetryable

      public static boolean isRetryable(SpringAIErrorMapper.ErrorCategory category)
      根据错误的类别来判断该错误是否可以重试。
      Parameters:
      category - the error category
      Returns:
      true if the error is potentially retryable
    • getRetryDelay

      public static long getRetryDelay(SpringAIErrorMapper.RetryStrategy strategy, int attempt)
      根据重试策略,获取建议的重试前等待时间(即延迟时间)。
      Parameters:
      strategy - the retry strategy
      attempt - the retry attempt number (0-based)
      Returns:
      delay in milliseconds