Behandlung von Fehlern in Retrofit 2.0
Ich möchte Fehler in Retrofit 2.0 behandeln
Got z.B.code=404
undbody=null
, abererrorBody()
enthält Daten inErrorModel
(Boolean status
undString info
).
Das isterrorBody().content
: [text=\n{"status":false,"info":"Provided email doesn't exist."}]
.
Wie kann ich diese Daten erhalten?
Danke, dass du mir geholfen hast!
Dies ist mein Code für die Nachrüstanforderung:
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...");
}
});