Class OpenConfigException

All Implemented Interfaces:
Serializable

public class OpenConfigException extends OpenException
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 Details

    • OpenConfigException

      public OpenConfigException(String message)
      Create exception with message 创建带消息的异常
      Parameters:
      message - error message | 错误消息
    • OpenConfigException

      public OpenConfigException(String message, Throwable cause)
      Create exception with message and cause 创建带消息和原因的异常
      Parameters:
      message - error message | 错误消息
      cause - throwable cause | 异常原因
    • OpenConfigException

      public OpenConfigException(String configKey, String configSource, String message)
      Create exception with config key, source and message 创建带配置键、源和消息的异常
      Parameters:
      configKey - configuration key | 配置键
      configSource - configuration source | 配置源
      message - error message | 错误消息
    • OpenConfigException

      public OpenConfigException(String configKey, String configSource, String message, Throwable cause)
      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

      public String configKey()
      Get configuration key 获取配置键
      Returns:
      configuration key or null | 配置键或null
    • configSource

      public String configSource()
      Get configuration source 获取配置源
      Returns:
      configuration source or null | 配置源或null
    • keyNotFound

      public static OpenConfigException keyNotFound(String key)
      Configuration key not found 配置键未找到
      Parameters:
      key - configuration key | 配置键
      Returns:
      exception instance | 异常实例
    • requiredKeyMissing

      public static OpenConfigException requiredKeyMissing(String key)
      Required configuration missing 必填配置缺失
      Parameters:
      key - configuration key | 配置键
      Returns:
      exception instance | 异常实例
    • conversionFailed

      public static OpenConfigException conversionFailed(String key, String value, Class<?> targetType)
      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

      public static OpenConfigException sourceLoadFailed(String source, Throwable cause)
      Configuration source load failed 配置源加载失败
      Parameters:
      source - configuration source | 配置源
      cause - throwable cause | 异常原因
      Returns:
      exception instance | 异常实例
    • sourceNotSupported

      public static OpenConfigException sourceNotSupported(String uri)
      Configuration source not supported 配置源不支持
      Parameters:
      uri - configuration source URI | 配置源URI
      Returns:
      exception instance | 异常实例
    • placeholderResolveFailed

      public static OpenConfigException placeholderResolveFailed(String placeholder)
      Placeholder resolution failed 占位符解析失败
      Parameters:
      placeholder - placeholder expression | 占位符表达式
      Returns:
      exception instance | 异常实例
    • placeholderRecursionTooDeep

      public static OpenConfigException placeholderRecursionTooDeep(String value)
      Placeholder recursion too deep 占位符递归过深
      Parameters:
      value - configuration value | 配置值
      Returns:
      exception instance | 异常实例
    • bindFailed

      public static OpenConfigException bindFailed(String prefix, Class<?> targetType, Throwable cause)
      Configuration binding failed 配置绑定失败
      Parameters:
      prefix - configuration prefix | 配置前缀
      targetType - target type | 目标类型
      cause - throwable cause | 异常原因
      Returns:
      exception instance | 异常实例
    • fieldBindFailed

      public static OpenConfigException fieldBindFailed(String fieldName, Throwable cause)
      Field binding failed 字段绑定失败
      Parameters:
      fieldName - field name | 字段名
      cause - throwable cause | 异常原因
      Returns:
      exception instance | 异常实例
    • validationFailed

      public static OpenConfigException validationFailed(String errors)
      Configuration validation failed 配置验证失败
      Parameters:
      errors - validation errors | 验证错误
      Returns:
      exception instance | 异常实例
    • invalidBoolean

      public static OpenConfigException invalidBoolean(String value)
      Invalid boolean value 无效布尔值
      Parameters:
      value - configuration value | 配置值
      Returns:
      exception instance | 异常实例
    • invalidUrl

      public static OpenConfigException invalidUrl(String url, Throwable cause)
      Invalid URL 无效URL
      Parameters:
      url - URL string | URL字符串
      cause - throwable cause | 异常原因
      Returns:
      exception instance | 异常实例
    • converterNotFound

      public static OpenConfigException converterNotFound(Class<?> type)
      Converter not found for type 类型转换器未找到
      Parameters:
      type - target type | 目标类型
      Returns:
      exception instance | 异常实例
    • decryptionFailed

      public static OpenConfigException decryptionFailed(Throwable cause)
      Configuration decryption failed 配置解密失败
      Parameters:
      cause - throwable cause | 异常原因
      Returns:
      exception instance | 异常实例