Class OpenException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
cloud.opencode.base.core.exception.OpenException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
OpenIOException, OpenTimeoutException, OpenUnsupportedOperationException
OpenException - Unified exception base class for OpenCode components
OpenException - OpenCode 组件统一异常基类
Base exception for all OpenCode components with error code and component name support.
所有组件异常都应继承此类,支持错误码和组件名称,便于异常分类和定位。
Important | 重要说明:
Note that OpenIllegalArgumentException and OpenIllegalStateException do NOT extend this class.
They extend IllegalArgumentException and IllegalStateException respectively,
so catch(OpenException e) will NOT catch those exceptions.
注意:OpenIllegalArgumentException 和 OpenIllegalStateException 并不继承此类。
它们分别继承自 IllegalArgumentException 和 IllegalStateException,
因此 catch(OpenException e) 无法捕获这两类异常。
Features | 主要功能:
- Error code support - 错误码支持
- Component name support - 组件名称支持
- Formatted message output [Component] (Code) Message - 格式化消息输出
- RuntimeException (unchecked) - 非受检异常
Usage Examples | 使用示例:
throw new OpenException("Operation failed");
throw new OpenException("Core", "CORE_001", "Parameter required");
throw new OpenException("IO failed", 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 Summary
ConstructorsConstructorDescriptionOpenException(String message) Creates 创建异常OpenException(String component, String errorCode, String message) Creates 创建异常(带组件和错误码)OpenException(String component, String errorCode, String message, Throwable cause) Creates 创建异常(完整参数)OpenException(String message, Throwable cause) Creates 创建异常(带原因) -
Method Summary
Modifier and TypeMethodDescriptionGets 获取组件名称Gets 获取错误码Gets 获取格式化的异常消息Gets 获取原始消息(不含组件和错误码前缀)Methods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
OpenException
-
OpenException
-
OpenException
-
OpenException
-
-
Method Details
-
getErrorCode
-
getComponent
-
getRawMessage
-
getMessage
Gets 获取格式化的异常消息格式: [组件] (错误码) 消息
- Overrides:
getMessagein classThrowable- Returns:
- the result | 格式化的消息
-