Ich möchte Fehler in Retrofit 2.0So behandeln Sie Fehler in Retrofit 2.0
behandeln z. code=404
und body=null
, aber errorBody()
enthält Daten in ErrorModel
(Boolean status
und String info
).
Dies ist errorBody().content
: [text=\n{"status":false,"info":"Provided email doesn't exist."}]
.
Wie kann ich diese Daten bekommen?
Vielen Dank für Ihre Hilfe!
Dies ist mein Code für Anfrage Retrofit:
ResetPasswordApi.Factory.getInstance().resetPassword(loginEditText.getText().toString())
.enqueue(new Callback<StatusInfoModel>() {
@Override
public void onResponse(Call<StatusInfoModel> call, Response<StatusInfoModel> response) {
if (response.isSuccessful()) {
showToast(getApplicationContext(), getString(R.string.new_password_sent));
} else {
showToast(getApplicationContext(), getString(R.string.email_not_exist));
}
}
@Override
public void onFailure(Call<StatusInfoModel> call, Throwable t) {
showToast(getApplicationContext(), "Something went wrong...");
}
});
können Sie einen Code eingeben – Raghunandan
Dieser Code meinen Sie? – y07k2