How can I register a global error converter on retrofit 2 + rx-android?
<p>My server returns domain java objects when everything goes ok, but returns an ErrorResponse object when there is an error. (EDIT: server returns http code 40x, and a json body with error info)
How can I register a global error converter on retrofit 2 + rx-android to avoid doing the same thing on every single call?</p>

<p>Currently I'm doing it like this on every call:</p>

<pre><code>MyApiRx.doSomething(params)
  .subscribeOn(Schedulers.io())
  .subscribe(response -&gt; responseHandler(),
             throwable -&gt; {
               HttpException err = (HttpException) throwable;
               Converter&lt;ResponseBody, ErrorResponse&gt; ec = retrofit.responseConverter(ErrorResponse.class, new Annotation[]{});
               ErrorResponse errorResponse =  ec.convert(err.response().errorBody());
             });
</code></pre>

<p>Maybe I should write a custom CallAdapterFactory that would handle this automatically, and would return an Observable with an onError(ErrorResponse err) instead of the stock onError(Throwable t)?</p>

<p>Any ideas on how to achive this?</p>

<p>Is it a good idea?</p>