Class OpenParallelException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
cloud.opencode.base.core.exception.OpenException
cloud.opencode.base.parallel.exception.OpenParallelException
- All Implemented Interfaces:
Serializable
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 Summary
ConstructorsConstructorDescriptionOpenParallelException(String message) Constructs a new parallel exception with message.OpenParallelException(String message, Throwable cause) Constructs a new parallel exception with message and cause.OpenParallelException(String message, List<Throwable> suppressed, int failedCount, int totalCount) Constructs a new parallel exception with full details. -
Method Summary
Modifier and TypeMethodDescriptionstatic OpenParallelExceptionCreates an all-failed exception.static OpenParallelExceptionexecutionFailed(String message, Throwable cause) Creates an execution failed exception.intGets the number of failed tasks.intGets the number of successful tasks.Gets the suppressed exceptions.intGets the total number of tasks.static OpenParallelExceptioninterrupted(InterruptedException cause) Creates an interrupted exception.static OpenParallelExceptionpartialFailure(List<Throwable> failures, int totalCount) Creates a partial failure exception.static OpenParallelExceptionCreates a timeout exception.Methods inherited from class OpenException
getComponent, getErrorCode, getMessage, getRawMessageMethods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
OpenParallelException
Constructs a new parallel exception with message. 使用消息构造新的并行异常。- Parameters:
message- the detail message - 详细消息
-
OpenParallelException
-
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
-
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
Creates a timeout exception. 创建超时异常。- Parameters:
timeout- the timeout duration - 超时时长- Returns:
- the exception - 异常
-
interrupted
Creates an interrupted exception. 创建中断异常。- Parameters:
cause- the cause - 原因- Returns:
- the exception - 异常
-
partialFailure
Creates a partial failure exception. 创建部分失败异常。- Parameters:
failures- the failed exceptions - 失败的异常列表totalCount- the total task count - 总任务数- Returns:
- the exception - 异常
-
allFailed
Creates an all-failed exception. 创建全部失败异常。- Parameters:
failures- the failed exceptions - 失败的异常列表- Returns:
- the exception - 异常
-
executionFailed
Creates an execution failed exception. 创建执行失败异常。- Parameters:
message- the message - 消息cause- the cause - 原因- Returns:
- the exception - 异常
-