Skip to content

Instantly share code, notes, and snippets.

@riggaroo
Created April 13, 2016 17:27
Show Gist options
  • Save riggaroo/e8b41845dbb26f721a77336f6c96f23c to your computer and use it in GitHub Desktop.
Save riggaroo/e8b41845dbb26f721a77336f6c96f23c to your computer and use it in GitHub Desktop.
Retrofit 2.0 - Parsing Error Responses
public static BaseResponseDto parseError(Response<?> response) {
Converter<ResponseBody, BaseResponseDto> converter =
Injection.getRetrofitInstance()
.responseBodyConverter(BaseResponseDto.class, new Annotation[0]);
BaseResponseDto error;
try {
error = converter.convert(response.errorBody());
} catch (IOException e) {
return new BaseResponseDto();
}
return error;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment