Class ConfigurationException

  • All Implemented Interfaces:
    Serializable

    public class ConfigurationException
    extends RuntimeException
    Exception thrown when a required configuration value is missing or invalid.

    This exception is used by methods like ConfNG.getRequired(ConfNGKey) to indicate that a mandatory configuration value could not be found in any configuration source.

    Example usage:

    
     try {
         String dbUrl = ConfNG.getRequired(MyConfig.DATABASE_URL);
     } catch (ConfigurationException e) {
         // Handle missing required configuration
         System.err.println("Missing required config: " + e.getKey());
     }
     
    Since:
    1.1.0
    Author:
    Bharat Kumar Malviya, GitHub: github.com/imBharatMalviya
    See Also:
    ConfNG.getRequired(ConfNGKey), Serialized Form
    • Constructor Detail

      • ConfigurationException

        public ConfigurationException​(String key)
        Creates a new ConfigurationException for a missing required configuration.
        Parameters:
        key - the configuration key that was missing
      • ConfigurationException

        public ConfigurationException​(String key,
                                      String message)
        Creates a new ConfigurationException with a custom message.
        Parameters:
        key - the configuration key
        message - the error message
      • ConfigurationException

        public ConfigurationException​(String key,
                                      String message,
                                      Throwable cause)
        Creates a new ConfigurationException with a cause.
        Parameters:
        key - the configuration key
        message - the error message
        cause - the underlying cause
    • Method Detail

      • getKey

        public String getKey()
        Gets the configuration key that caused this exception.
        Returns:
        the configuration key
      • getErrorMessage

        public String getErrorMessage()
        Gets the error message.
        Returns:
        the error message