Skip to content

Commit

Permalink
chore: Display user friendly error message for wrong credentials (#1905)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShridharGoel authored and iamareebjamal committed Aug 18, 2019
1 parent 6c3a691 commit c95b98c
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import javax.inject.Inject;

import io.reactivex.disposables.CompositeDisposable;
import retrofit2.HttpException;

import static com.eventyay.organizer.common.Constants.PREF_USER_EMAIL;

Expand Down Expand Up @@ -84,7 +85,18 @@ public void login() {
encryptUserCredentials();
actionLogin.call();
},
throwable -> error.setValue(ErrorUtils.getMessage(throwable).toString())));
throwable -> {
if (throwable instanceof HttpException) {
int errorCode = ((HttpException) throwable).code();

if (errorCode == 401)
error.setValue("Please check the credentials you have entered");
else
error.setValue(ErrorUtils.getMessage(throwable).toString());
} else {
error.setValue(ErrorUtils.getMessage(throwable).toString());
}
}));
}

public void setBaseUrl() {
Expand Down

0 comments on commit c95b98c

Please sign in to comment.