Class OpenConfigException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
cloud.opencode.base.core.exception.OpenException
cloud.opencode.base.config.OpenConfigException
- All Implemented Interfaces:
Serializable
Configuration Component Exception
配置组件异常
This exception is thrown when configuration operations fail, including loading errors, conversion errors, validation errors, and other configuration-related issues.
此异常在配置操作失败时抛出,包括加载错误、转换错误、验证错误和其他配置相关问题。
Features | 主要功能:
- Configuration key tracking - 配置键跟踪
- Configuration source identification - 配置源识别
- Type conversion error details - 类型转换错误详情
- Factory methods for common errors - 常见错误的工厂方法
Usage Examples | 使用示例:
// Key not found
throw OpenConfigException.keyNotFound("database.url");
// Conversion failed
throw OpenConfigException.conversionFailed("port", "abc", Integer.class);
// Source load failed
throw OpenConfigException.sourceLoadFailed("config.properties", cause);
Security | 安全性:
- Thread-safe: Yes - 线程安全: 是
- Immutable: Yes - 不可变: 是
- Since:
- JDK 25, opencode-base-config V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionOpenConfigException(String message) Create exception with message 创建带消息的异常OpenConfigException(String configKey, String configSource, String message) Create exception with config key, source and message 创建带配置键、源和消息的异常OpenConfigException(String configKey, String configSource, String message, Throwable cause) Create exception with config key, source, message and cause 创建带配置键、源、消息和原因的异常OpenConfigException(String message, Throwable cause) Create exception with message and cause 创建带消息和原因的异常 -
Method Summary
Modifier and TypeMethodDescriptionstatic OpenConfigExceptionbindFailed(String prefix, Class<?> targetType, Throwable cause) Configuration binding failed 配置绑定失败Get configuration key 获取配置键Get configuration source 获取配置源static OpenConfigExceptionconversionFailed(String key, String value, Class<?> targetType) Type conversion failed 类型转换失败static OpenConfigExceptionconversionFailed(String key, String value, Class<?> targetType, Throwable cause) Type conversion failed with cause 类型转换失败(带原因)static OpenConfigExceptionconverterNotFound(Class<?> type) Converter not found for type 类型转换器未找到static OpenConfigExceptiondecryptionFailed(Throwable cause) Configuration decryption failed 配置解密失败static OpenConfigExceptionfieldBindFailed(String fieldName, Throwable cause) Field binding failed 字段绑定失败static OpenConfigExceptioninvalidBoolean(String value) Invalid boolean value 无效布尔值static OpenConfigExceptioninvalidUrl(String url, Throwable cause) Invalid URL 无效URLstatic OpenConfigExceptionkeyNotFound(String key) Configuration key not found 配置键未找到static OpenConfigExceptionPlaceholder recursion too deep 占位符递归过深static OpenConfigExceptionplaceholderResolveFailed(String placeholder) Placeholder resolution failed 占位符解析失败static OpenConfigExceptionrequiredKeyMissing(String key) Required configuration missing 必填配置缺失static OpenConfigExceptionsourceLoadFailed(String source, Throwable cause) Configuration source load failed 配置源加载失败static OpenConfigExceptionsourceNotSupported(String uri) Configuration source not supported 配置源不支持static OpenConfigExceptionvalidationFailed(String errors) Configuration validation failed 配置验证失败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
-
OpenConfigException
Create exception with message 创建带消息的异常- Parameters:
message- error message | 错误消息
-
OpenConfigException
-
OpenConfigException
-
OpenConfigException
Create exception with config key, source, message and cause 创建带配置键、源、消息和原因的异常- Parameters:
configKey- configuration key | 配置键configSource- configuration source | 配置源message- error message | 错误消息cause- throwable cause | 异常原因
-
-
Method Details
-
configKey
-
configSource
Get configuration source 获取配置源- Returns:
- configuration source or null | 配置源或null
-
keyNotFound
Configuration key not found 配置键未找到- Parameters:
key- configuration key | 配置键- Returns:
- exception instance | 异常实例
-
requiredKeyMissing
Required configuration missing 必填配置缺失- Parameters:
key- configuration key | 配置键- Returns:
- exception instance | 异常实例
-
conversionFailed
Type conversion failed 类型转换失败- Parameters:
key- configuration key | 配置键value- configuration value | 配置值targetType- target type | 目标类型- Returns:
- exception instance | 异常实例
-
conversionFailed
public static OpenConfigException conversionFailed(String key, String value, Class<?> targetType, Throwable cause) Type conversion failed with cause 类型转换失败(带原因)- Parameters:
key- configuration key | 配置键value- configuration value | 配置值targetType- target type | 目标类型cause- throwable cause | 异常原因- Returns:
- exception instance | 异常实例
-
sourceLoadFailed
Configuration source load failed 配置源加载失败- Parameters:
source- configuration source | 配置源cause- throwable cause | 异常原因- Returns:
- exception instance | 异常实例
-
sourceNotSupported
Configuration source not supported 配置源不支持- Parameters:
uri- configuration source URI | 配置源URI- Returns:
- exception instance | 异常实例
-
placeholderResolveFailed
Placeholder resolution failed 占位符解析失败- Parameters:
placeholder- placeholder expression | 占位符表达式- Returns:
- exception instance | 异常实例
-
placeholderRecursionTooDeep
Placeholder recursion too deep 占位符递归过深- Parameters:
value- configuration value | 配置值- Returns:
- exception instance | 异常实例
-
bindFailed
Configuration binding failed 配置绑定失败- Parameters:
prefix- configuration prefix | 配置前缀targetType- target type | 目标类型cause- throwable cause | 异常原因- Returns:
- exception instance | 异常实例
-
fieldBindFailed
Field binding failed 字段绑定失败- Parameters:
fieldName- field name | 字段名cause- throwable cause | 异常原因- Returns:
- exception instance | 异常实例
-
validationFailed
Configuration validation failed 配置验证失败- Parameters:
errors- validation errors | 验证错误- Returns:
- exception instance | 异常实例
-
invalidBoolean
Invalid boolean value 无效布尔值- Parameters:
value- configuration value | 配置值- Returns:
- exception instance | 异常实例
-
invalidUrl
Invalid URL 无效URL- Parameters:
url- URL string | URL字符串cause- throwable cause | 异常原因- Returns:
- exception instance | 异常实例
-
converterNotFound
Converter not found for type 类型转换器未找到- Parameters:
type- target type | 目标类型- Returns:
- exception instance | 异常实例
-
decryptionFailed
Configuration decryption failed 配置解密失败- Parameters:
cause- throwable cause | 异常原因- Returns:
- exception instance | 异常实例
-