Class OpenIOException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
cloud.opencode.base.core.exception.OpenException
cloud.opencode.base.core.exception.OpenIOException
- All Implemented Interfaces:
OpenExceptionMeta, Serializable
IO Exception Wrapper - Wrap checked IOException as unchecked
IO 异常包装 - 将受检 IOException 包装为非受检异常
Wraps checked IOException as unchecked exception to simplify exception handling.
将受检的 IOException 包装为非受检异常,简化异常处理。
Features | 主要功能:
- Wrap IOException (wrap) - 包装 IOException
- Read failure factory (readFailed) - 读取失败工厂
- Write failure factory (writeFailed) - 写入失败工厂
- File not found factory (fileNotFound) - 文件未找到工厂
- Close failure factory (closeFailed) - 关闭失败工厂
Usage Examples | 使用示例:
try {
Files.readString(path);
} catch (IOException e) {
throw new OpenIOException("Failed to read file", e);
}
// Static factory methods - 静态工厂方法
throw OpenIOException.readFailed(path, e);
throw OpenIOException.writeFailed(path, e);
throw OpenIOException.fileNotFound(path);
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
ConstructorsConstructorDescriptionOpenIOException(String message) Creates 创建 IO 异常OpenIOException(String errorCode, String message, Throwable cause) Creates 创建 IO 异常(指定错误码)OpenIOException(String message, Throwable cause) Creates 创建 IO 异常(包装原始 IOException) -
Method Summary
Modifier and TypeMethodDescriptionstatic OpenIOExceptioncloseFailed(String resource, Throwable cause) Creates 创建"关闭资源失败"异常static OpenIOExceptionfileNotFound(String resource) Creates 创建"文件未找到"异常static OpenIOExceptionfileNotFound(Path path) Creates 创建"文件未找到"异常static OpenIOExceptionreadFailed(String resource, Throwable cause) Creates 创建"读取失败"异常static OpenIOExceptionreadFailed(Path path, Throwable cause) Creates 创建"读取失败"异常static OpenIOExceptionwrap(IOException cause) Wraps 包装 IOExceptionstatic OpenIOExceptionwriteFailed(String resource, Throwable cause) Creates 创建"写入失败"异常static OpenIOExceptionwriteFailed(Path path, Throwable cause) Creates 创建"写入失败"异常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
-
OpenIOException
-
OpenIOException
-
OpenIOException
-
-
Method Details
-
wrap
Wraps 包装 IOException- Parameters:
cause- the value | 原始 IOException- Returns:
- the result | 异常实例
-
readFailed
Creates 创建"读取失败"异常- Parameters:
path- the value | 文件路径cause- the value | 原始异常- Returns:
- the result | 异常实例
-
readFailed
Creates 创建"读取失败"异常- Parameters:
resource- the value | 资源名cause- the value | 原始异常- Returns:
- the result | 异常实例
-
writeFailed
Creates 创建"写入失败"异常- Parameters:
path- the value | 文件路径cause- the value | 原始异常- Returns:
- the result | 异常实例
-
writeFailed
Creates 创建"写入失败"异常- Parameters:
resource- the value | 资源名cause- the value | 原始异常- Returns:
- the result | 异常实例
-
fileNotFound
Creates 创建"文件未找到"异常- Parameters:
path- the value | 文件路径- Returns:
- the result | 异常实例
-
fileNotFound
Creates 创建"文件未找到"异常- Parameters:
resource- the value | 资源名- Returns:
- the result | 异常实例
-
closeFailed
Creates 创建"关闭资源失败"异常- Parameters:
resource- the value | 资源名cause- the value | 原始异常- Returns:
- the result | 异常实例
-