Class OpenParallelException

All Implemented Interfaces:
OpenExceptionMeta, Serializable

public class OpenParallelException extends OpenException
Open Parallel Exception - Parallel Execution Exception Open 并行异常 - 并行执行异常

This exception is thrown when parallel task execution fails, including timeout, interruption, and partial failures.

当并行任务执行失败时抛出此异常,包括超时、中断和部分失败。

Example | 示例:

try {
    OpenParallel.invokeAll(tasks, Duration.ofSeconds(10));
} catch (OpenParallelException e) {
    log.error("Failed: {}/{}", e.getFailedCount(), e.getTotalCount());
    e.getSuppressedExceptions().forEach(ex -> log.warn("Suppressed: ", ex));
}

Features | 主要功能:

  • Suppressed exception tracking - 被抑制异常跟踪
  • Failed/total task count - 失败/总任务计数
  • Factory methods for common errors - 常见错误的工厂方法
  • Extends OpenException for unified handling - 继承OpenException统一处理

Security | 安全性:

  • Thread-safe: Yes (immutable after construction) - 线程安全: 是(构造后不可变)
Since:
JDK 25, opencode-base-parallel V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • OpenParallelException

      public OpenParallelException(String message)
      Constructs a new parallel exception with message. 使用消息构造新的并行异常。
      Parameters:
      message - the detail message - 详细消息
    • OpenParallelException

      public OpenParallelException(String message, Throwable cause)
      Constructs a new parallel exception with message and cause. 使用消息和原因构造新的并行异常。
      Parameters:
      message - the detail message - 详细消息
      cause - the cause - 原因
    • OpenParallelException

      public OpenParallelException(String message, List<Throwable> suppressed, int failedCount, int totalCount)
      Constructs a new parallel exception with full details. 使用完整详情构造新的并行异常。
      Parameters:
      message - the detail message - 详细消息
      suppressed - the suppressed exceptions - 被抑制的异常
      failedCount - the number of failed tasks - 失败的任务数
      totalCount - the total number of tasks - 总任务数
  • Method Details

    • getSuppressedExceptions

      public List<Throwable> getSuppressedExceptions()
      Gets the suppressed exceptions. 获取被抑制的异常。
      Returns:
      the suppressed exceptions - 被抑制的异常
    • getFailedCount

      public int getFailedCount()
      Gets the number of failed tasks. 获取失败的任务数。
      Returns:
      the failed count - 失败数
    • getTotalCount

      public int getTotalCount()
      Gets the total number of tasks. 获取总任务数。
      Returns:
      the total count - 总数
    • getSuccessCount

      public int getSuccessCount()
      Gets the number of successful tasks. 获取成功的任务数。
      Returns:
      the success count - 成功数
    • timeout

      public static OpenParallelException timeout(Duration timeout)
      Creates a timeout exception. 创建超时异常。
      Parameters:
      timeout - the timeout duration - 超时时长
      Returns:
      the exception - 异常
    • interrupted

      public static OpenParallelException interrupted(InterruptedException cause)
      Creates an interrupted exception. 创建中断异常。
      Parameters:
      cause - the cause - 原因
      Returns:
      the exception - 异常
    • partialFailure

      public static OpenParallelException partialFailure(List<Throwable> failures, int totalCount)
      Creates a partial failure exception. 创建部分失败异常。
      Parameters:
      failures - the failed exceptions - 失败的异常列表
      totalCount - the total task count - 总任务数
      Returns:
      the exception - 异常
    • allFailed

      public static OpenParallelException allFailed(List<Throwable> failures)
      Creates an all-failed exception. 创建全部失败异常。
      Parameters:
      failures - the failed exceptions - 失败的异常列表
      Returns:
      the exception - 异常
    • executionFailed

      public static OpenParallelException executionFailed(String message, Throwable cause)
      Creates an execution failed exception. 创建执行失败异常。
      Parameters:
      message - the message - 消息
      cause - the cause - 原因
      Returns:
      the exception - 异常