Class OpenPdfException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
cloud.opencode.base.core.exception.OpenException
cloud.opencode.base.pdf.exception.OpenPdfException
- All Implemented Interfaces:
Serializable
PDF Exception - Base exception for all PDF operations
PDF 异常 - 所有 PDF 操作的基础异常
This exception is thrown when PDF operations fail, including parsing,
writing, signing, and form processing errors. Extends OpenException
to integrate with the OpenCode unified exception hierarchy.
当 PDF 操作失败时抛出此异常,包括解析、写入、签名和表单处理错误。
继承 OpenException 以集成 OpenCode 统一异常体系。
Features | 主要功能:
- Operation type tracking - 操作类型跟踪
- Page number association for page-specific errors - 页面相关错误的页码关联
- Factory methods for common error scenarios - 常见错误场景的工厂方法
- Error code support via OpenException - 通过 OpenException 支持错误码
- Component name "PDF" auto-prefixed in messages - 消息中自动添加 "PDF" 组件前缀
Usage Examples | 使用示例:
throw OpenPdfException.invalidFormat("Missing header");
throw OpenPdfException.readFailed("/path/to/file.pdf", cause);
throw OpenPdfException.invalidPageNumber(5, 3);
Security | 安全性:
- Thread-safe: Yes — immutable after construction - 线程安全: 是 — 构造后不可变
- Null-safe: Partial — message is required, operation and pageNumber may be null - 空值安全: 部分 — 消息必填,操作和页码可为空
- Since:
- JDK 25, opencode-base-pdf V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionOpenPdfException(String message) Creates exception with message 创建带消息的异常OpenPdfException(String operation, int pageNumber, String message) Creates exception with operation, page number and message 创建带操作、页码和消息的异常OpenPdfException(String operation, String message) Creates exception with operation and message 创建带操作和消息的异常OpenPdfException(String operation, String message, Throwable cause) Creates exception with operation, message and cause 创建带操作、消息和原因的异常OpenPdfException(String message, Throwable cause) Creates exception with message and cause 创建带消息和原因的异常 -
Method Summary
Modifier and TypeMethodDescriptionstatic OpenPdfExceptionfieldNotFound(String fieldName) Creates exception for form field not found 创建表单字段未找到异常static OpenPdfExceptioninvalidFormat(String reason) Creates exception for invalid PDF format 创建无效 PDF 格式异常static OpenPdfExceptioninvalidPageNumber(int pageNumber, int totalPages) Creates exception for invalid page number 创建无效页码异常static OpenPdfExceptionmergeFailed(String reason, Throwable cause) Creates exception for merge failure 创建合并失败异常Gets the operation type 获取操作类型Gets the page number 获取页码static OpenPdfExceptionCreates exception for password required 创建需要密码异常static OpenPdfExceptionreadFailed(String path, Throwable cause) Creates exception for read failure 创建读取失败异常static OpenPdfExceptionsignatureFailed(String reason, Throwable cause) Creates exception for signature failure 创建签名失败异常static OpenPdfExceptionsplitFailed(String reason, Throwable cause) Creates exception for split failure 创建拆分失败异常static OpenPdfExceptionunsupportedFeature(String feature) Creates exception for unsupported feature 创建不支持功能异常static OpenPdfExceptionwriteFailed(String path, Throwable cause) Creates exception for write failure 创建写入失败异常static OpenPdfExceptionCreates exception for wrong password 创建密码错误异常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
-
OpenPdfException
Creates exception with message 创建带消息的异常- Parameters:
message- error message | 错误消息
-
OpenPdfException
-
OpenPdfException
-
OpenPdfException
-
OpenPdfException
-
-
Method Details
-
operation
-
pageNumber
Gets the page number 获取页码- Returns:
- page number, or null if not applicable | 页码,如不适用则返回 null
-
invalidFormat
Creates exception for invalid PDF format 创建无效 PDF 格式异常- Parameters:
reason- reason description | 原因描述- Returns:
- OpenPdfException
-
readFailed
Creates exception for read failure 创建读取失败异常- Parameters:
path- file path | 文件路径cause- root cause | 根本原因- Returns:
- OpenPdfException
-
writeFailed
Creates exception for write failure 创建写入失败异常- Parameters:
path- file path | 文件路径cause- root cause | 根本原因- Returns:
- OpenPdfException
-
invalidPageNumber
Creates exception for invalid page number 创建无效页码异常- Parameters:
pageNumber- page number | 页码totalPages- total pages in document | 文档总页数- Returns:
- OpenPdfException
-
passwordRequired
Creates exception for password required 创建需要密码异常- Returns:
- OpenPdfException
-
wrongPassword
Creates exception for wrong password 创建密码错误异常- Returns:
- OpenPdfException
-
signatureFailed
Creates exception for signature failure 创建签名失败异常- Parameters:
reason- reason description | 原因描述cause- root cause | 根本原因- Returns:
- OpenPdfException
-
fieldNotFound
Creates exception for form field not found 创建表单字段未找到异常- Parameters:
fieldName- field name | 字段名- Returns:
- OpenPdfException
-
unsupportedFeature
Creates exception for unsupported feature 创建不支持功能异常- Parameters:
feature- feature name | 功能名称- Returns:
- OpenPdfException
-
mergeFailed
Creates exception for merge failure 创建合并失败异常- Parameters:
reason- reason description | 原因描述cause- root cause | 根本原因- Returns:
- OpenPdfException
-
splitFailed
Creates exception for split failure 创建拆分失败异常- Parameters:
reason- reason description | 原因描述cause- root cause | 根本原因- Returns:
- OpenPdfException
-