Class OpenYmlException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
cloud.opencode.base.core.exception.OpenException
cloud.opencode.base.yml.exception.OpenYmlException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
YmlBindException, YmlParseException, YmlPathException, YmlPlaceholderException, YmlSecurityException
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 Summary
ConstructorsConstructorDescriptionOpenYmlException(String message) Constructs an exception with message.OpenYmlException(String message, int line, int column) Constructs an exception with message and location.OpenYmlException(String errorCode, String message) Constructs an exception with error code and message.OpenYmlException(String errorCode, String message, int line, int column) Constructs an exception with error code, message and location.OpenYmlException(String errorCode, String message, Throwable cause) Constructs an exception with error code, message and cause.OpenYmlException(String errorCode, String message, Throwable cause, int line, int column) Constructs an exception with error code, message, cause and location.OpenYmlException(String message, Throwable cause) Constructs an exception with message and cause.OpenYmlException(String message, Throwable cause, int line, int column) Constructs an exception with message, cause and location. -
Method Summary
Modifier and TypeMethodDescriptionintGets the column number where the error occurred.intgetLine()Gets the line number where the error occurred.booleanChecks if location information is available.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
-
OpenYmlException
Constructs an exception with message. 构造带消息的异常。- Parameters:
message- the detail message | 详细消息
-
OpenYmlException
-
OpenYmlException
-
OpenYmlException
-
OpenYmlException
Constructs an exception with message and location. 构造带消息和位置的异常。- Parameters:
message- the detail message | 详细消息line- the line number | 行号column- the column number | 列号
-
OpenYmlException
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
-
OpenYmlException
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
-