Class OpenDeepCloneException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
cloud.opencode.base.core.exception.OpenException
cloud.opencode.base.deepclone.exception.OpenDeepCloneException
- All Implemented Interfaces:
OpenExceptionMeta, Serializable
Exception for deep clone operations
深度克隆操作异常
This exception is thrown when errors occur during object cloning, such as instantiation failures, field access errors, or circular reference issues.
当对象克隆过程中发生错误时抛出此异常,如实例化失败、字段访问错误或循环引用问题。
Features | 主要功能:
- Target type tracking - 目标类型跟踪
- Clone path tracking - 克隆路径跟踪
- Factory methods for common errors - 常见错误的工厂方法
Usage Examples | 使用示例:
throw OpenDeepCloneException.instantiationFailed(MyClass.class, cause);
throw OpenDeepCloneException.maxDepthExceeded(100, "a.b.c.d");
throw OpenDeepCloneException.unsupportedType(SomeClass.class);
Security | 安全性:
- Thread-safe: Yes (immutable after construction) - 线程安全: 是(构造后不可变)
- Since:
- JDK 25, opencode-base-deepclone V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionOpenDeepCloneException(Class<?> targetType, String path, String message) Creates an exception with target type, path, and message 使用目标类型、路径和消息创建异常OpenDeepCloneException(Class<?> targetType, String path, String message, Throwable cause) Creates an exception with target type, path, message, and cause 使用目标类型、路径、消息和原因创建异常OpenDeepCloneException(String message) Creates an exception with a message 使用消息创建异常OpenDeepCloneException(String message, Throwable cause) Creates an exception with a message and cause 使用消息和原因创建异常 -
Method Summary
Modifier and TypeMethodDescriptionstatic OpenDeepCloneExceptioncircularReference(Class<?> type, String path) Creates an exception for circular reference detection 创建循环引用检测的异常static OpenDeepCloneExceptionfieldAccessFailed(String field, Class<?> type, Throwable cause) Creates an exception for field access failure 创建字段访问失败的异常getPath()Gets the clone path where the error occurred 获取发生错误的克隆路径Class<?> Gets the target type being cloned 获取正在克隆的目标类型static OpenDeepCloneExceptioninstantiationFailed(Class<?> type, Throwable cause) Creates an exception for instantiation failure 创建实例化失败的异常static OpenDeepCloneExceptionmaxDepthExceeded(int depth, String path) Creates an exception for exceeding maximum clone depth 创建超过最大克隆深度的异常static OpenDeepCloneExceptionserializationFailed(Class<?> type, Throwable cause) Creates an exception for serialization failure 创建序列化失败的异常static OpenDeepCloneExceptionunsupportedType(Class<?> type) Creates an exception for unsupported type 创建不支持类型的异常Methods inherited from class OpenException
getComponent, getErrorCode, getMessage, getRawMessageMethods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface OpenExceptionMeta
getMetaPrefix
-
Constructor Details
-
OpenDeepCloneException
Creates an exception with a message 使用消息创建异常- Parameters:
message- the error message | 错误消息
-
OpenDeepCloneException
-
OpenDeepCloneException
-
OpenDeepCloneException
Creates an exception with target type, path, message, and cause 使用目标类型、路径、消息和原因创建异常- Parameters:
targetType- the type being cloned | 正在克隆的类型path- the clone path | 克隆路径message- the error message | 错误消息cause- the cause | 原因
-
-
Method Details
-
getTargetType
Gets the target type being cloned 获取正在克隆的目标类型- Returns:
- the target type, may be null | 目标类型,可能为null
-
getPath
Gets the clone path where the error occurred 获取发生错误的克隆路径- Returns:
- the path, may be null | 路径,可能为null
-
maxDepthExceeded
Creates an exception for exceeding maximum clone depth 创建超过最大克隆深度的异常- Parameters:
depth- the depth reached | 达到的深度path- the clone path | 克隆路径- Returns:
- the exception | 异常
-
unsupportedType
Creates an exception for unsupported type 创建不支持类型的异常- Parameters:
type- the unsupported type | 不支持的类型- Returns:
- the exception | 异常
-
instantiationFailed
Creates an exception for instantiation failure 创建实例化失败的异常- Parameters:
type- the type that failed to instantiate | 无法实例化的类型cause- the cause | 原因- Returns:
- the exception | 异常
-
fieldAccessFailed
public static OpenDeepCloneException fieldAccessFailed(String field, Class<?> type, Throwable cause) Creates an exception for field access failure 创建字段访问失败的异常- Parameters:
field- the field name | 字段名type- the declaring type | 声明类型cause- the cause | 原因- Returns:
- the exception | 异常
-
serializationFailed
Creates an exception for serialization failure 创建序列化失败的异常- Parameters:
type- the type that failed to serialize | 无法序列化的类型cause- the cause | 原因- Returns:
- the exception | 异常
-
circularReference
Creates an exception for circular reference detection 创建循环引用检测的异常- Parameters:
type- the type with circular reference | 存在循环引用的类型path- the clone path | 克隆路径- Returns:
- the exception | 异常
-