Class YmlBindException

All Implemented Interfaces:
OpenExceptionMeta, Serializable

public class YmlBindException extends OpenYmlException
YAML Bind Exception - Thrown when configuration binding fails YAML 绑定异常 - 当配置绑定失败时抛出

This exception is thrown when YAML content cannot be bound to a Java object.

当 YAML 内容无法绑定到 Java 对象时抛出此异常。

Features | 主要功能:

  • Tracks property path and target type for diagnostic info - 跟踪属性路径和目标类型以提供诊断信息
  • Supports required field validation errors - 支持必填字段验证错误
  • Error code YML_BIND_001 - 错误码 YML_BIND_001

Usage Examples | 使用示例:

try {
    YmlBinder.bind(document, ServerConfig.class);
} catch (YmlBindException e) {
    System.err.println("Path: " + e.getPath());
    System.err.println("Type: " + e.getTargetType());
}

Security | 安全性:

  • Thread-safe: Yes (immutable after construction) - 线程安全: 是(构建后不可变)
  • Null-safe: Yes (path and targetType may be null) - 空值安全: 是(路径和目标类型可为空)
Since:
JDK 25, opencode-base-yml V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • YmlBindException

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

      public YmlBindException(String path, Class<?> targetType, Throwable cause)
      Constructs a bind exception with path, target type and cause. 构造带路径、目标类型和原因的绑定异常。
      Parameters:
      path - the property path | 属性路径
      targetType - the target type | 目标类型
      cause - the cause | 原因
    • YmlBindException

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

      public YmlBindException(String path, Class<?> targetType)
      Constructs a bind exception for required field. 为必填字段构造绑定异常。
      Parameters:
      path - the property path | 属性路径
      targetType - the target type | 目标类型
  • Method Details

    • getPath

      public String getPath()
      Gets the property path that failed to bind. 获取绑定失败的属性路径。
      Returns:
      the property path | 属性路径
    • getTargetType

      public Class<?> getTargetType()
      Gets the target type for binding. 获取绑定的目标类型。
      Returns:
      the target type | 目标类型