Skip to content

Commit

Permalink
Polish
Browse files Browse the repository at this point in the history
Polish gh-4595
  • Loading branch information
shakuzen committed Jan 31, 2024
1 parent 33bb267 commit 3a6923d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package io.micrometer.registry.otlp;

import io.micrometer.core.instrument.config.InvalidConfigurationException;
import io.micrometer.core.instrument.config.validate.Validated;
import io.micrometer.core.instrument.push.PushRegistryConfig;

Expand Down Expand Up @@ -138,7 +139,7 @@ default Map<String, String> headers() {
headersString = URLDecoder.decode(headersString, "UTF-8");
}
catch (Exception e) {
throw new IllegalArgumentException("Cannot decode header value: " + headersString, e);
throw new InvalidConfigurationException("Cannot URL decode header value: " + headersString, e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package io.micrometer.registry.otlp;

import io.micrometer.core.instrument.config.InvalidConfigurationException;
import org.junit.jupiter.api.Test;

import java.util.Collections;
Expand Down Expand Up @@ -73,8 +74,8 @@ void headersUseEnvVarWhenConfigNotSet() throws Exception {
void headersDecodingError() throws Exception {
OtlpConfig config = k -> null;
withEnvironmentVariable("OTEL_EXPORTER_OTLP_HEADERS", "header2=%-1").execute(() -> {
assertThatThrownBy(config::headers).isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot decode header value: header2=%-1,");
assertThatThrownBy(config::headers).isInstanceOf(InvalidConfigurationException.class)
.hasMessage("Cannot URL decode header value: header2=%-1,");
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@
*/
public class InvalidConfigurationException extends IllegalStateException {

/**
* Construct an exception indication invalid configuration with the specified detail
* message and cause.
* @param message the detail message (which is saved for later retrieval by the
* {@link Throwable#getMessage()} method).
* @param cause the cause (which is saved for later retrieval by the
* {@link Throwable#getCause()} method). (A {@code null} value is permitted, and
* indicates that the cause is nonexistent or unknown.)
* @since 1.11.9
*/
public InvalidConfigurationException(String message, Throwable cause) {
super(message, cause);
}

public InvalidConfigurationException(String s) {
super(s);
}
Expand Down

0 comments on commit 3a6923d

Please sign in to comment.