use of com.palantir.logsafe.exceptions.SafeNullPointerException in project conjure-java-runtime by palantir.
the class EndpointNameHeaderEnrichmentContract method processMetadata.
@Override
protected void processMetadata(Class<?> targetType, Method method, MethodMetadata metadata) {
String httpMethod = metadata.template().method();
if (httpMethod == null) {
throw new SafeNullPointerException("An HTTP method is required", SafeArg.of("class", targetType.getSimpleName()), SafeArg.of("method", method.getName()));
}
try {
HttpMethod.valueOf(httpMethod.toUpperCase(Locale.ENGLISH));
} catch (IllegalArgumentException e) {
throw new SafeIllegalArgumentException("Unsupported HTTP method", SafeArg.of("class", targetType.getSimpleName()), SafeArg.of("method", method.getName()), SafeArg.of("httpMethod", httpMethod));
}
metadata.template().header(ENDPOINT_NAME_HEADER, method.getName());
}
Aggregations