Created
April 13, 2016 17:27
-
-
Save riggaroo/e8b41845dbb26f721a77336f6c96f23c to your computer and use it in GitHub Desktop.
Retrofit 2.0 - Parsing Error Responses
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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