Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(retrofit) : give custom message for RetrofitException response body convert error #1077

Conversation

SheetalAtre
Copy link
Contributor

feat(retrofit) : give custom message for RetrofitException response body convert error

@@ -67,16 +73,38 @@ public Response getResponse() {
* @throws RuntimeException wrapping the underlying IOException if unable to convert the body to
* the specified {@code type}.
*/
public <T> T getErrorBodyAs(Class<T> type) {
public Map getErrorBodyAs() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public Map getErrorBodyAs() {
public Map<String, Object> getErrorBodyAs() {

@@ -45,8 +49,10 @@ public static RetrofitException httpError(Response response, Retrofit retrofit)
*/
private final Retrofit retrofit;

RetrofitException(String message, Response response, Retrofit retrofit) {
super(message);
private static Map<String, Object> jsonErrorResponseBody;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private static Map<String, Object> jsonErrorResponseBody;
private static Map<String, Object> jsonErrorResponseBody = Map.of("message", "failed to parse response");

@SheetalAtre SheetalAtre force-pushed the retrofitException_responseBody_convertError branch 2 times, most recently from 9bf0def to a699bb5 Compare July 17, 2023 16:13
}
}

static {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From here below can disappear now, yes?

@SheetalAtre SheetalAtre force-pushed the retrofitException_responseBody_convertError branch from a833b10 to 11c41b1 Compare July 19, 2023 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants