NetworkFailure/ApiFailure and Moshi exceptions? #84
-
DescriptionHi, in my project I have following Retrofit instance: val retrofit = Retrofit.Builder()
.baseUrl(...)
.addConverterFactory(ApiResultConverterFactory)
.addConverterFactory(MoshiConverterFactory.create(moshi))
.addCallAdapterFactory(ApiResultCallAdapterFactory)
.client(okHttpClient)
.build() When there's some JSON malformation in the response, Moshi's converter throws What is the recommended way to handle this? I'd like to transform those Moshi's exceptions into It's more a question if there's a suggested way how to handle this, or maybe there would be a possibility to introduce some parameter to |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You would need to write your own intercepting JsonAdapter to capture those and rethrow them with your own exception. This is what we do in Slack's network stack and the intended pattern for this scenario in EitherNet. |
Beta Was this translation helpful? Give feedback.
You would need to write your own intercepting JsonAdapter to capture those and rethrow them with your own exception. This is what we do in Slack's network stack and the intended pattern for this scenario in EitherNet.