From dbbc62867b334f684c7a8f75dfa2c103b9327df7 Mon Sep 17 00:00:00 2001 From: xibz Date: Tue, 5 Nov 2024 09:36:30 -0600 Subject: [PATCH] feature(retrofit): Add exception handler to service factory (#1185) 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 Co-authored-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))