Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Address discussion comment

...

This KIP proposes the introduction of another constructor ConfigException(String message, Throwable cause) to adhere to the convention and the addition of another constructor to capture cause.

Public Interfaces

Code Block
languagejava
titleConfigException.java
// Deprecate existing constructor
@Deprecated
public ConfigException(String name, Object value) {
	this(name, value, null);
}

// New Constructor
public ConfigException(String message, Throwable cause) {
	super(message, cause);
}

// New Constructor
public ConfigException(String name, Object value, String message, Throwable cause) {
	super("Invalid value " + value + " for configuration " + name + (message == null ? "" : ": " + message), cause);
}

// Update existing constructor
public ConfigException(String name, Object value, String message) {
	this(name, value, message, null);
}


Proposed Changes


We deprecate the existing constructor which takes an Object  as the second argument and introduce a new one which accepts a Throwable  as the cause instead ConfigException(String name, Object value)   and introduce ConfigException(String message, Throwable cause) . We also update existing usages of the former constructor as it will be marked deprecated.


We also add ConfigException(String name, Object value, String message, Throwable cause) and make ConfigException(String name, Object value, String message)  delegate to it. This will be useful in scenarios where we use the latter when catching an exception so as to not lose the underlying cause.

Compatibility, Deprecation, and Migration Plan

...