From 3bcb353992f3e37027427f105d7e3b57b608a887 Mon Sep 17 00:00:00 2001 From: benjamin-j-powell Date: Thu, 30 May 2024 16:06:20 -0500 Subject: [PATCH] feature(retrofit): Add exception handler to service factory This commit adds the SpinnakerRetrofitErrorHandler to service factories which allows for clients that rely on service factories to properly have RetrofitErrors be converted to some Spinnaker*Exception. Signed-off-by: benjamin-j-powell --- .../netflix/spinnaker/kork/retrofit/RetrofitServiceFactory.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kork-retrofit/src/main/java/com/netflix/spinnaker/kork/retrofit/RetrofitServiceFactory.java b/kork-retrofit/src/main/java/com/netflix/spinnaker/kork/retrofit/RetrofitServiceFactory.java index 40465bec5..53b32c5ba 100644 --- a/kork-retrofit/src/main/java/com/netflix/spinnaker/kork/retrofit/RetrofitServiceFactory.java +++ b/kork-retrofit/src/main/java/com/netflix/spinnaker/kork/retrofit/RetrofitServiceFactory.java @@ -25,6 +25,7 @@ import com.netflix.spinnaker.config.okhttp3.OkHttpClientProvider; import com.netflix.spinnaker.kork.annotations.NonnullByDefault; import com.netflix.spinnaker.kork.client.ServiceClientFactory; +import com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerRetrofitErrorHandler; import com.netflix.spinnaker.retrofit.Slf4jRetrofitLogger; import retrofit.Endpoint; import retrofit.RequestInterceptor; @@ -54,6 +55,7 @@ public T create(Class type, ServiceEndpoint serviceEndpoint, ObjectMapper .setRequestInterceptor(spinnakerRequestInterceptor) .setConverter(new JacksonConverter(objectMapper)) .setEndpoint(endpoint) + .setErrorHandler(SpinnakerRetrofitErrorHandler.getInstance()) .setClient(new Ok3Client(clientProvider.getClient(serviceEndpoint))) .setLogLevel(retrofitLogLevel) .setLog(new Slf4jRetrofitLogger(type))