Class OpenSerializationException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
cloud.opencode.base.core.exception.OpenException
cloud.opencode.base.serialization.exception.OpenSerializationException
- All Implemented Interfaces:
OpenExceptionMeta, Serializable
OpenSerializationException - Serialization Exception
序列化异常
Exception thrown when serialization or deserialization operations fail.
当序列化或反序列化操作失败时抛出的异常。
Features | 主要功能:
- Serialize failure handling - 序列化失败处理
- Deserialize failure handling - 反序列化失败处理
- Serializer not found handling - 序列化器未找到处理
- Unsupported type handling - 不支持的类型处理
- Compression/Decompression failure handling - 压缩/解压失败处理
Usage Examples | 使用示例:
throw OpenSerializationException.serializeFailed(obj, cause);
throw OpenSerializationException.deserializeFailed(data, type, cause);
throw OpenSerializationException.serializerNotFound("msgpack");
Security | 安全性:
- Thread-safe: Yes (immutable) - 线程安全: 是 (不可变)
- Serializable: Yes - 可序列化: 是
- Since:
- JDK 25, opencode-base-serialization V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionOpenSerializationException(String message) Creates a serialization exception with message.OpenSerializationException(String message, String format, Class<?> targetType, Throwable cause) Creates a serialization exception with full details.OpenSerializationException(String message, Throwable cause) Creates a serialization exception with message and cause. -
Method Summary
Modifier and TypeMethodDescriptionstatic OpenSerializationExceptioncompressionFailed(String algorithm, Throwable cause) Creates exception for compression failure with algorithm.static OpenSerializationExceptioncompressionFailed(Throwable cause) Creates exception for compression failure.static OpenSerializationExceptiondecompressionFailed(String algorithm, Throwable cause) Creates exception for decompression failure with algorithm.static OpenSerializationExceptiondecompressionFailed(Throwable cause) Creates exception for decompression failure.static OpenSerializationExceptiondeserializeFailed(byte[] data, Class<?> type, String format, Throwable cause) Creates exception for deserialization failure with format.static OpenSerializationExceptiondeserializeFailed(byte[] data, Class<?> type, Throwable cause) Creates exception for deserialization failure.Returns the serialization format.Class<?> Returns the target type.static OpenSerializationExceptionmissingDependency(String format, String dependency) Creates exception for missing dependency.static OpenSerializationExceptionserializeFailed(Object obj, String format, Throwable cause) Creates exception for serialization failure with format.static OpenSerializationExceptionserializeFailed(Object obj, Throwable cause) Creates exception for serialization failure.static OpenSerializationExceptionserializerNotFound(String format) Creates exception when serializer is not found.static OpenSerializationExceptionunsupportedType(Class<?> type, String format) Creates exception for unsupported type.static OpenSerializationExceptionunsupportedType(Type type, String format) Creates 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
-
OpenSerializationException
Creates a serialization exception with message. 创建带消息的序列化异常。- Parameters:
message- the error message - 错误消息
-
OpenSerializationException
-
OpenSerializationException
public OpenSerializationException(String message, String format, Class<?> targetType, Throwable cause) Creates a serialization exception with full details. 创建带完整详情的序列化异常。- Parameters:
message- the error message - 错误消息format- the serialization format - 序列化格式targetType- the target type - 目标类型cause- the cause - 原因
-
-
Method Details
-
getFormat
Returns the serialization format. 返回序列化格式。- Returns:
- the format, may be null - 格式,可能为 null
-
getTargetType
Returns the target type. 返回目标类型。- Returns:
- the target type, may be null - 目标类型,可能为 null
-
serializeFailed
Creates exception for serialization failure. 创建序列化失败异常。- Parameters:
obj- the object that failed to serialize - 序列化失败的对象cause- the cause - 原因- Returns:
- the exception - 异常
-
serializeFailed
public static OpenSerializationException serializeFailed(Object obj, String format, Throwable cause) Creates exception for serialization failure with format. 创建带格式的序列化失败异常。- Parameters:
obj- the object that failed to serialize - 序列化失败的对象format- the serialization format - 序列化格式cause- the cause - 原因- Returns:
- the exception - 异常
-
deserializeFailed
public static OpenSerializationException deserializeFailed(byte[] data, Class<?> type, Throwable cause) Creates exception for deserialization failure. 创建反序列化失败异常。- Parameters:
data- the data that failed to deserialize - 反序列化失败的数据type- the target type - 目标类型cause- the cause - 原因- Returns:
- the exception - 异常
-
deserializeFailed
public static OpenSerializationException deserializeFailed(byte[] data, Class<?> type, String format, Throwable cause) Creates exception for deserialization failure with format. 创建带格式的反序列化失败异常。- Parameters:
data- the data that failed to deserialize - 反序列化失败的数据type- the target type - 目标类型format- the serialization format - 序列化格式cause- the cause - 原因- Returns:
- the exception - 异常
-
serializerNotFound
Creates exception when serializer is not found. 创建序列化器未找到异常。- Parameters:
format- the requested format - 请求的格式- Returns:
- the exception - 异常
-
unsupportedType
Creates exception for unsupported type. 创建不支持类型异常。- Parameters:
type- the unsupported type - 不支持的类型format- the serialization format - 序列化格式- Returns:
- the exception - 异常
-
unsupportedType
Creates exception for unsupported type. 创建不支持类型异常。- Parameters:
type- the unsupported type - 不支持的类型format- the serialization format - 序列化格式- Returns:
- the exception - 异常
-
compressionFailed
Creates exception for compression failure. 创建压缩失败异常。- Parameters:
cause- the cause - 原因- Returns:
- the exception - 异常
-
compressionFailed
Creates exception for compression failure with algorithm. 创建带算法的压缩失败异常。- Parameters:
algorithm- the compression algorithm - 压缩算法cause- the cause - 原因- Returns:
- the exception - 异常
-
decompressionFailed
Creates exception for decompression failure. 创建解压失败异常。- Parameters:
cause- the cause - 原因- Returns:
- the exception - 异常
-
decompressionFailed
Creates exception for decompression failure with algorithm. 创建带算法的解压失败异常。- Parameters:
algorithm- the compression algorithm - 压缩算法cause- the cause - 原因- Returns:
- the exception - 异常
-
missingDependency
Creates exception for missing dependency. 创建缺少依赖异常。- Parameters:
format- the format requiring the dependency - 需要依赖的格式dependency- the missing dependency - 缺少的依赖- Returns:
- the exception - 异常
-