Class TestException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
cloud.opencode.base.core.exception.OpenException
cloud.opencode.base.test.exception.TestException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AssertionException, BenchmarkException, DataGenerationException, MockException
Test Exception - Base exception for test operations
测试异常 - 测试操作的基础异常
Base exception for all test-related errors, extending OpenException
with test-specific error codes.
所有测试相关错误的基础异常,继承 OpenException 并提供测试专用错误码。
Features | 主要功能:
- Extends OpenException for unified error handling - 继承 OpenException 统一异常处理
- Test error code support - 测试错误码支持
- Formatted message: [Test] (TEST-xxxx) message - 格式化消息
Usage Examples | 使用示例:
throw new TestException(TestErrorCode.ASSERTION_FAILED, "Values differ");
Security | 安全性:
- Thread-safe: Yes (immutable after construction) - 线程安全: 是(构造后不可变)
- Since:
- JDK 25, opencode-base-test V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionTestException(TestErrorCode errorCode) Create test exception with error code 使用错误码创建测试异常TestException(TestErrorCode errorCode, String detail) Create test exception with error code and detail 使用错误码和详情创建测试异常TestException(TestErrorCode errorCode, Throwable cause) Create test exception with error code and cause 使用错误码和原因创建测试异常TestException(String message) Create test exception with message 使用消息创建测试异常TestException(String message, Throwable cause) Create test exception with message and cause 使用消息和原因创建测试异常 -
Method Summary
Modifier and TypeMethodDescriptionGet the typed test error code 获取类型化的测试错误码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
-
TestException
Create test exception with error code 使用错误码创建测试异常- Parameters:
errorCode- the error code | 错误码
-
TestException
Create test exception with error code and detail 使用错误码和详情创建测试异常- Parameters:
errorCode- the error code | 错误码detail- the detail message | 详细消息
-
TestException
Create test exception with error code and cause 使用错误码和原因创建测试异常- Parameters:
errorCode- the error code | 错误码cause- the cause | 原因
-
TestException
Create test exception with message 使用消息创建测试异常- Parameters:
message- the message | 消息
-
TestException
-
-
Method Details
-
getTestErrorCode
Get the typed test error code 获取类型化的测试错误码- Returns:
- the test error code | 测试错误码
-