Class OpenXmlException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
cloud.opencode.base.core.exception.OpenException
cloud.opencode.base.xml.exception.OpenXmlException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
XmlBindException, XmlParseException, XmlSecurityException, XmlTransformException, XmlValidationException, XmlXPathException
XML Exception Base Class - Base exception for all XML operations
XML 异常基类 - 所有 XML 操作的基础异常
This exception serves as the base class for all XML-related exceptions in the framework. It provides location information (line and column) for parse errors.
此异常作为框架中所有 XML 相关异常的基类,为解析错误提供位置信息(行号和列号)。
Exception Hierarchy | 异常继承体系:
OpenException (OpenCode统一异常基类)
└── OpenXmlException (XML异常基类)
├── XmlParseException # 解析异常
├── XmlXPathException # XPath异常
├── XmlBindException # 绑定异常
├── XmlTransformException # 转换异常
├── XmlValidationException # 验证异常
└── XmlSecurityException # 安全异常
Features | 主要功能:
- Base exception for all XML operations - 所有 XML 操作的基础异常
- Line and column location info for parse errors - 解析错误的行号和列号位置信息
- Exception hierarchy root for XML module - XML 模块的异常继承体系根
- Inherits error code and component name from OpenException - 继承 OpenException 的错误码和组件名称
Usage Examples | 使用示例:
// Catch base XML exception
try {
OpenXml.parse(xmlString);
} catch (OpenXmlException e) {
System.err.println("XML error: " + e.getMessage());
}
- Since:
- JDK 25, opencode-base-xml V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionOpenXmlException(String message) Constructs an exception with a message.OpenXmlException(String message, int line, int column) Constructs an exception with location information.OpenXmlException(String message, int line, int column, Throwable cause) Constructs an exception with location information and cause.OpenXmlException(String message, Throwable cause) Constructs an exception with a message and cause.OpenXmlException(Throwable cause) Constructs an exception with a cause. -
Method Summary
Modifier and TypeMethodDescriptionstatic OpenXmlExceptionCreates a bind error exception.intReturns the column number where the error occurred.intgetLine()Returns the line number where the error occurred.booleanReturns whether location information is available.static OpenXmlExceptionparseError(String message, int line, int column) Creates a parse error exception.static OpenXmlExceptiontransformError(Throwable cause) Creates a transform error exception.static OpenXmlExceptionvalidationError(String message) Creates a validation error exception.static OpenXmlExceptionxpathError(String xpath, Throwable cause) Creates an XPath error 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
-
OpenXmlException
Constructs an exception with a message. 构造带消息的异常。- Parameters:
message- the detail message | 详细消息
-
OpenXmlException
-
OpenXmlException
Constructs an exception with a cause. 构造带原因的异常。- Parameters:
cause- the cause | 原因
-
OpenXmlException
Constructs an exception with location information. 构造带位置信息的异常。- Parameters:
message- the detail message | 详细消息line- the line number | 行号column- the column number | 列号
-
OpenXmlException
-
-
Method Details
-
getLine
public int getLine()Returns the line number where the error occurred. 返回发生错误的行号。- Returns:
- the line number, or -1 if not available | 行号,如果不可用则返回 -1
-
getColumn
public int getColumn()Returns the column number where the error occurred. 返回发生错误的列号。- Returns:
- the column number, or -1 if not available | 列号,如果不可用则返回 -1
-
hasLocation
public boolean hasLocation()Returns whether location information is available. 返回位置信息是否可用。- Returns:
- true if location is available | 如果位置可用则返回 true
-
parseError
Creates a parse error exception. 创建解析错误异常。- Parameters:
message- the error message | 错误消息line- the line number | 行号column- the column number | 列号- Returns:
- the exception | 异常
-
xpathError
Creates an XPath error exception. 创建 XPath 错误异常。- Parameters:
xpath- the XPath expression | XPath 表达式cause- the cause | 原因- Returns:
- the exception | 异常
-
bindError
Creates a bind error exception. 创建绑定错误异常。- Parameters:
type- the target type | 目标类型cause- the cause | 原因- Returns:
- the exception | 异常
-
validationError
Creates a validation error exception. 创建验证错误异常。- Parameters:
message- the error message | 错误消息- Returns:
- the exception | 异常
-
transformError
Creates a transform error exception. 创建转换错误异常。- Parameters:
cause- the cause | 原因- Returns:
- the exception | 异常
-