Class OpenXmlException

All Implemented Interfaces:
OpenExceptionMeta, Serializable
Direct Known Subclasses:
XmlBindException, XmlParseException, XmlSecurityException, XmlTransformException, XmlValidationException, XmlXPathException

public class OpenXmlException extends OpenException
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 Details

    • OpenXmlException

      public OpenXmlException(String message)
      Constructs an exception with a message. 构造带消息的异常。
      Parameters:
      message - the detail message | 详细消息
    • OpenXmlException

      public OpenXmlException(String message, Throwable cause)
      Constructs an exception with a message and cause. 构造带消息和原因的异常。
      Parameters:
      message - the detail message | 详细消息
      cause - the cause | 原因
    • OpenXmlException

      public OpenXmlException(Throwable cause)
      Constructs an exception with a cause. 构造带原因的异常。
      Parameters:
      cause - the cause | 原因
    • OpenXmlException

      public OpenXmlException(String message, int line, int column)
      Constructs an exception with location information. 构造带位置信息的异常。
      Parameters:
      message - the detail message | 详细消息
      line - the line number | 行号
      column - the column number | 列号
    • OpenXmlException

      public OpenXmlException(String message, int line, int column, Throwable cause)
      Constructs an exception with location information and cause. 构造带位置信息和原因的异常。
      Parameters:
      message - the detail message | 详细消息
      line - the line number | 行号
      column - the column number | 列号
      cause - the cause | 原因
  • 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

      public static OpenXmlException parseError(String message, int line, int column)
      Creates a parse error exception. 创建解析错误异常。
      Parameters:
      message - the error message | 错误消息
      line - the line number | 行号
      column - the column number | 列号
      Returns:
      the exception | 异常
    • xpathError

      public static OpenXmlException xpathError(String xpath, Throwable cause)
      Creates an XPath error exception. 创建 XPath 错误异常。
      Parameters:
      xpath - the XPath expression | XPath 表达式
      cause - the cause | 原因
      Returns:
      the exception | 异常
    • bindError

      public static OpenXmlException bindError(Class<?> type, Throwable cause)
      Creates a bind error exception. 创建绑定错误异常。
      Parameters:
      type - the target type | 目标类型
      cause - the cause | 原因
      Returns:
      the exception | 异常
    • validationError

      public static OpenXmlException validationError(String message)
      Creates a validation error exception. 创建验证错误异常。
      Parameters:
      message - the error message | 错误消息
      Returns:
      the exception | 异常
    • transformError

      public static OpenXmlException transformError(Throwable cause)
      Creates a transform error exception. 创建转换错误异常。
      Parameters:
      cause - the cause | 原因
      Returns:
      the exception | 异常