code: public ErrorResponse parseError(Response response) {
      if (response.isSuccessful()) {
        throw new IllegalArgumentException("Response must be unsuccessful.");
      }
  
      Converter<ResponseBody, ErrorResponse> responseBodyObjectConverter =
        retrofit.responseBodyConverter(ErrorResponse.class, new Annotation[0]);
  
      try {
        return responseBodyObjectConverter.convert(response.errorBody());
      } catch (IOException ex) {
        throw new RuntimeException("Could not parse error response", ex);
      }
    }
docs: A helper to assist with decoding unsuccessful responses.
  
  This is not done automatically, because an unsuccessful result may have many causes
  such as network issues, intervening HTTP proxies, load balancers, partial responses, etc,
  which means that a response can easily be incomplete, or not even the expected well-formed
  JSON error.
  
  Therefore, even when using this helper, be prepared for it to throw an exception instead of
  successfully decoding every error response!
  
  @param response the unsuccessful response object to deserialize.
  @return the resulting {@link ErrorResponse}, assuming deserialization succeeded.
  @throws RuntimeException if the response cannot be deserialized