Class OpenTimeoutException

All Implemented Interfaces:
OpenExceptionMeta, Serializable

public class OpenTimeoutException extends OpenException
Timeout Exception - Operation timeout exception 超时异常 - 操作超时异常

Thrown when an operation exceeds the specified time limit.

当操作超过预定时间限制时抛出此异常。

Features | 主要功能:

  • Duration support (getTimeout) - Duration 支持
  • Static factory (of) - 静态工厂方法
  • Auto duration formatting (ms/s/m) - 自动时长格式化
  • Cause chain support - 原因链支持

Usage Examples | 使用示例:

if (elapsedTime > timeout) {
    throw new OpenTimeoutException("Operation timed out after " + timeout + "ms");
}

// Static factory methods - 静态工厂方法
throw OpenTimeoutException.of("Database query", Duration.ofSeconds(30));
throw OpenTimeoutException.of("HTTP request", Duration.ofMinutes(1), cause);

Security | 安全性:

  • Thread-safe: Yes (immutable) - 线程安全: 是 (不可变)
  • Serializable: Yes - 可序列化: 是
Since:
JDK 25, opencode-base-core V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • OpenTimeoutException

      public OpenTimeoutException(String message)
      Creates 创建超时异常
      Parameters:
      message - the value | 异常消息
    • OpenTimeoutException

      public OpenTimeoutException(String message, Throwable cause)
      Creates 创建超时异常(带原因)
      Parameters:
      message - the value | 异常消息
      cause - the value | 原始异常
    • OpenTimeoutException

      public OpenTimeoutException(String message, Duration timeout)
      Creates 创建超时异常(带超时时长)
      Parameters:
      message - the value | 异常消息
      timeout - the value | 超时时长
    • OpenTimeoutException

      public OpenTimeoutException(String message, Duration timeout, Throwable cause)
      Creates 创建超时异常(完整参数)
      Parameters:
      message - the value | 异常消息
      timeout - the value | 超时时长
      cause - the value | 原始异常
  • Method Details

    • getTimeout

      public Duration getTimeout()
      Gets 获取超时时长
      Returns:
      the result | 超时时长,可能为 null
    • of

      public static OpenTimeoutException of(String operation, Duration timeout)
      Creates 创建超时异常
      Parameters:
      operation - the operation name | 操作名称
      timeout - the value | 超时时长
      Returns:
      the result | 异常实例
    • of

      public static OpenTimeoutException of(String operation, Duration timeout, Throwable cause)
      Creates 创建超时异常(带原因)
      Parameters:
      operation - the operation name | 操作名称
      timeout - the value | 超时时长
      cause - the value | 原始异常
      Returns:
      the result | 异常实例