Class OpenYmlException

All Implemented Interfaces:
OpenExceptionMeta, Serializable
Direct Known Subclasses:
YmlBindException, YmlParseException, YmlPathException, YmlPlaceholderException, YmlSecurityException

public class OpenYmlException extends OpenException
Open YAML Exception - Base exception for YAML operations YAML 异常基类 - YAML 操作的基础异常

This is the base class for all YAML-related exceptions in this module. It extends OpenException with component "yml" and supports line/column location tracking for parse errors.

这是本模块中所有 YAML 相关异常的基类。 它继承自 OpenException,组件名为 "yml",并支持 解析错误的行列位置跟踪。

Features | 主要功能:

  • Line and column location tracking for parse errors - 解析错误的行列位置跟踪
  • Base class for all YAML exceptions (parse, bind, path, security) - 所有 YAML 异常的基类
  • Error code and component support via OpenException - 通过 OpenException 支持错误码和组件名

Usage Examples | 使用示例:

try {
    OpenYml.parse(invalidYaml);
} catch (OpenYmlException e) {
    if (e.hasLocation()) {
        System.err.println("Error at line " + e.getLine());
    }
    System.err.println("Error code: " + e.getErrorCode());
}

Security | 安全性:

  • Thread-safe: Yes (immutable after construction) - 线程安全: 是(构建后不可变)
  • Null-safe: No (message may be null) - 空值安全: 否(消息可能为空)
Since:
JDK 25, opencode-base-yml V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • OpenYmlException

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

      public OpenYmlException(String errorCode, String message)
      Constructs an exception with error code and message. 构造带错误码和消息的异常。
      Parameters:
      errorCode - the error code | 错误码
      message - the detail message | 详细消息
    • OpenYmlException

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

      public OpenYmlException(String errorCode, String message, Throwable cause)
      Constructs an exception with error code, message and cause. 构造带错误码、消息和原因的异常。
      Parameters:
      errorCode - the error code | 错误码
      message - the detail message | 详细消息
      cause - the cause | 原因
    • OpenYmlException

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

      public OpenYmlException(String errorCode, String message, int line, int column)
      Constructs an exception with error code, message and location. 构造带错误码、消息和位置的异常。
      Parameters:
      errorCode - the error code | 错误码
      message - the detail message | 详细消息
      line - the line number | 行号
      column - the column number | 列号
    • OpenYmlException

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

      public OpenYmlException(String errorCode, String message, Throwable cause, int line, int column)
      Constructs an exception with error code, message, cause and location. 构造带错误码、消息、原因和位置的异常。
      Parameters:
      errorCode - the error code | 错误码
      message - the detail message | 详细消息
      cause - the cause | 原因
      line - the line number | 行号
      column - the column number | 列号
  • Method Details

    • getLine

      public int getLine()
      Gets the line number where the error occurred. 获取错误发生的行号。
      Returns:
      the line number, or -1 if unknown | 行号,如果未知则返回 -1
    • getColumn

      public int getColumn()
      Gets the column number where the error occurred. 获取错误发生的列号。
      Returns:
      the column number, or -1 if unknown | 列号,如果未知则返回 -1
    • hasLocation

      public boolean hasLocation()
      Checks if location information is available. 检查位置信息是否可用。
      Returns:
      true if location is available | 如果位置可用则返回 true