Class OpenIOOperationException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
cloud.opencode.base.core.exception.OpenException
cloud.opencode.base.io.exception.OpenIOOperationException
- All Implemented Interfaces:
Serializable
IO Operation Exception (Unchecked)
IO操作异常(非受检)
Unchecked exception for IO operations that wraps checked IOException. Simplifies caller code by eliminating mandatory try-catch blocks.
用于IO操作的非受检异常,封装受检的IOException。 通过消除强制性的try-catch块来简化调用方代码。
Features | 主要功能:
- Unchecked exception wrapper - 非受检异常包装
- Operation and path tracking - 操作和路径追踪
- Factory methods for common errors - 常见错误的工厂方法
Usage Examples | 使用示例:
// Create with factory method
throw OpenIOOperationException.fileNotFound(path);
// Create with operation details
throw new OpenIOOperationException("read", path.toString(), "File not readable");
Security | 安全性:
- Thread-safe: Yes (immutable after construction) - 线程安全: 是(构造后不可变)
- Null-safe: Yes, operation and path may be null - 空值安全: 是,operation和path可以为null
- Since:
- JDK 25, opencode-base-io V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionOpenIOOperationException(String message) Creates an exception with message 创建带消息的异常OpenIOOperationException(String operation, String path, String message) Creates an exception with operation, path and message 创建带操作、路径和消息的异常OpenIOOperationException(String operation, String path, String message, Throwable cause) Creates an exception with operation, path, message and cause 创建带操作、路径、消息和原因的异常OpenIOOperationException(String message, Throwable cause) Creates an exception with message and cause 创建带消息和原因的异常 -
Method Summary
Modifier and TypeMethodDescriptionstatic OpenIOOperationExceptionchecksumFailed(String algorithm, Throwable cause) Creates a checksum failed exception 创建校验和计算失败异常static OpenIOOperationExceptioncopyFailed(Path source, Path target, Throwable cause) Creates a copy failed exception 创建复制失败异常static OpenIOOperationExceptioncreateDirectoryFailed(Path path, Throwable cause) Creates a create directory failed exception 创建目录创建失败异常static OpenIOOperationExceptioncreateFileFailed(Path path, Throwable cause) Creates a create file failed exception 创建文件创建失败异常static OpenIOOperationExceptiondeleteFailed(Path path, Throwable cause) Creates a delete failed exception 创建删除失败异常static OpenIOOperationExceptionfileNotFound(Path path) Creates a file not found exception 创建文件未找到异常static OpenIOOperationExceptioninvalidPath(String path, Throwable cause) Creates an invalid path exception 创建无效路径异常static OpenIOOperationExceptionmoveFailed(Path source, Path target, Throwable cause) Creates a move failed exception 创建移动失败异常Gets the operation type 获取操作类型path()Gets the path involved 获取涉及的路径static OpenIOOperationExceptionreadFailed(Throwable cause) Creates a read failed exception for stream 创建流读取失败异常static OpenIOOperationExceptionreadFailed(Path path, Throwable cause) Creates a read failed exception 创建读取失败异常static OpenIOOperationExceptionresourceNotFound(String resource) Creates a resource not found exception 创建资源未找到异常static OpenIOOperationExceptionsizeLimitExceeded(long maxSize, long actualSize) Creates a size limit exceeded exception 创建大小超限异常static OpenIOOperationExceptionstreamOperationFailed(String operation, Throwable cause) Creates a stream operation failed exception 创建流操作失败异常static OpenIOOperationExceptionwatchFailed(Path path, Throwable cause) Creates a watch failed exception 创建监听失败异常static OpenIOOperationExceptionwriteFailed(Throwable cause) Creates a write failed exception for stream 创建流写入失败异常static OpenIOOperationExceptionwriteFailed(Path path, Throwable cause) Creates a write failed 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
-
OpenIOOperationException
Creates an exception with message 创建带消息的异常- Parameters:
message- the error message | 错误消息
-
OpenIOOperationException
-
OpenIOOperationException
-
OpenIOOperationException
Creates an exception with operation, path, message and cause 创建带操作、路径、消息和原因的异常- Parameters:
operation- the operation type | 操作类型path- the path involved | 涉及的路径message- the error message | 错误消息cause- the cause | 原因
-
-
Method Details
-
operation
-
path
-
fileNotFound
Creates a file not found exception 创建文件未找到异常- Parameters:
path- the file path | 文件路径- Returns:
- exception instance | 异常实例
-
resourceNotFound
Creates a resource not found exception 创建资源未找到异常- Parameters:
resource- the resource name | 资源名称- Returns:
- exception instance | 异常实例
-
readFailed
Creates a read failed exception 创建读取失败异常- Parameters:
path- the file path | 文件路径cause- the cause | 原因- Returns:
- exception instance | 异常实例
-
readFailed
Creates a read failed exception for stream 创建流读取失败异常- Parameters:
cause- the cause | 原因- Returns:
- exception instance | 异常实例
-
writeFailed
Creates a write failed exception 创建写入失败异常- Parameters:
path- the file path | 文件路径cause- the cause | 原因- Returns:
- exception instance | 异常实例
-
writeFailed
Creates a write failed exception for stream 创建流写入失败异常- Parameters:
cause- the cause | 原因- Returns:
- exception instance | 异常实例
-
copyFailed
Creates a copy failed exception 创建复制失败异常- Parameters:
source- the source path | 源路径target- the target path | 目标路径cause- the cause | 原因- Returns:
- exception instance | 异常实例
-
moveFailed
Creates a move failed exception 创建移动失败异常- Parameters:
source- the source path | 源路径target- the target path | 目标路径cause- the cause | 原因- Returns:
- exception instance | 异常实例
-
deleteFailed
Creates a delete failed exception 创建删除失败异常- Parameters:
path- the path | 路径cause- the cause | 原因- Returns:
- exception instance | 异常实例
-
createFileFailed
Creates a create file failed exception 创建文件创建失败异常- Parameters:
path- the path | 路径cause- the cause | 原因- Returns:
- exception instance | 异常实例
-
createDirectoryFailed
Creates a create directory failed exception 创建目录创建失败异常- Parameters:
path- the path | 路径cause- the cause | 原因- Returns:
- exception instance | 异常实例
-
streamOperationFailed
Creates a stream operation failed exception 创建流操作失败异常- Parameters:
operation- the operation name | 操作名称cause- the cause | 原因- Returns:
- exception instance | 异常实例
-
sizeLimitExceeded
Creates a size limit exceeded exception 创建大小超限异常- Parameters:
maxSize- the max size | 最大大小actualSize- the actual size | 实际大小- Returns:
- exception instance | 异常实例
-
invalidPath
Creates an invalid path exception 创建无效路径异常- Parameters:
path- the path | 路径cause- the cause | 原因- Returns:
- exception instance | 异常实例
-
watchFailed
Creates a watch failed exception 创建监听失败异常- Parameters:
path- the path | 路径cause- the cause | 原因- Returns:
- exception instance | 异常实例
-
checksumFailed
Creates a checksum failed exception 创建校验和计算失败异常- Parameters:
algorithm- the algorithm | 算法cause- the cause | 原因- Returns:
- exception instance | 异常实例
-