Class YmlPathException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
cloud.opencode.base.core.exception.OpenException
cloud.opencode.base.yml.exception.OpenYmlException
cloud.opencode.base.yml.exception.YmlPathException
- All Implemented Interfaces:
OpenExceptionMeta, Serializable
YAML Path Exception - Thrown when path access fails
YAML 路径异常 - 当路径访问失败时抛出
This exception is thrown when a path does not exist or is invalid.
当路径不存在或无效时抛出此异常。
Features | 主要功能:
- Tracks the failing path for diagnostics - 跟踪失败路径以供诊断
- Factory methods for index-out-of-bounds and type-mismatch errors - 索引越界和类型不匹配错误的工厂方法
- Error code YML_PATH_001 - 错误码 YML_PATH_001
Usage Examples | 使用示例:
try {
String value = PathResolver.get(data, "missing.path");
} catch (YmlPathException e) {
System.err.println("Path not found: " + e.getPath());
}
Security | 安全性:
- Thread-safe: Yes (immutable after construction) - 线程安全: 是(构建后不可变)
- Null-safe: No (path may be null) - 空值安全: 否(路径可能为空)
- Since:
- JDK 25, opencode-base-yml V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionYmlPathException(String path) Constructs a path exception for missing path.YmlPathException(String path, String message) Constructs a path exception with message.YmlPathException(String path, String message, Throwable cause) Constructs a path exception with message and cause. -
Method Summary
Modifier and TypeMethodDescriptiongetPath()Gets the path that caused the exception.static YmlPathExceptionindexOutOfBounds(String path, int index, int size) Creates an exception for index out of bounds.static YmlPathExceptiontypeMismatch(String path, String expected, String actual) Creates an exception for type mismatch.Methods inherited from class OpenYmlException
getColumn, getLine, hasLocationMethods inherited from class OpenException
getComponent, getErrorCode, getMessage, getRawMessageMethods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface OpenExceptionMeta
getMetaPrefix
-
Constructor Details
-
YmlPathException
Constructs a path exception for missing path. 为缺失路径构造路径异常。- Parameters:
path- the missing path | 缺失的路径
-
YmlPathException
-
YmlPathException
-
-
Method Details
-
getPath
-
indexOutOfBounds
Creates an exception for index out of bounds. 为索引越界创建异常。- Parameters:
path- the path | 路径index- the index | 索引size- the sequence size | 序列大小- Returns:
- the exception | 异常
-
typeMismatch
Creates an exception for type mismatch. 为类型不匹配创建异常。- Parameters:
path- the path | 路径expected- the expected type | 期望类型actual- the actual type | 实际类型- Returns:
- the exception | 异常
-