improve error reporting a bit
This commit is contained in:
parent
c28adf42b3
commit
4ec76ca88d
@ -51,6 +51,7 @@ public class ApiRequest extends AsyncTask<HashMap<String,String>, Integer, JsonE
|
|||||||
protected boolean m_canUseProgress = false;
|
protected boolean m_canUseProgress = false;
|
||||||
protected Context m_context;
|
protected Context m_context;
|
||||||
private SharedPreferences m_prefs;
|
private SharedPreferences m_prefs;
|
||||||
|
protected String m_lastErrorMessage;
|
||||||
|
|
||||||
protected ApiError m_lastError;
|
protected ApiError m_lastError;
|
||||||
|
|
||||||
@ -257,9 +258,11 @@ public class ApiRequest extends AsyncTask<HashMap<String,String>, Integer, JsonE
|
|||||||
return null;
|
return null;
|
||||||
} catch (javax.net.ssl.SSLPeerUnverifiedException e) {
|
} catch (javax.net.ssl.SSLPeerUnverifiedException e) {
|
||||||
m_lastError = ApiError.SSL_REJECTED;
|
m_lastError = ApiError.SSL_REJECTED;
|
||||||
|
m_lastErrorMessage = e.getMessage();
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
m_lastError = ApiError.IO_ERROR;
|
m_lastError = ApiError.IO_ERROR;
|
||||||
|
m_lastErrorMessage = e.getMessage();
|
||||||
|
|
||||||
if (e.getMessage() != null) {
|
if (e.getMessage() != null) {
|
||||||
if (e.getMessage().matches("Hostname [^ ]+ was not verified")) {
|
if (e.getMessage().matches("Hostname [^ ]+ was not verified")) {
|
||||||
@ -270,9 +273,11 @@ public class ApiRequest extends AsyncTask<HashMap<String,String>, Integer, JsonE
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (com.google.gson.JsonSyntaxException e) {
|
} catch (com.google.gson.JsonSyntaxException e) {
|
||||||
m_lastError = ApiError.PARSE_ERROR;
|
m_lastError = ApiError.PARSE_ERROR;
|
||||||
|
m_lastErrorMessage = e.getMessage();
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
m_lastError = ApiError.OTHER_ERROR;
|
m_lastError = ApiError.OTHER_ERROR;
|
||||||
|
m_lastErrorMessage = e.getMessage();
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,7 +381,13 @@ public class FeedCategoriesFragment extends BaseFeedlistFragment implements OnIt
|
|||||||
if (m_lastError == ApiError.LOGIN_FAILED) {
|
if (m_lastError == ApiError.LOGIN_FAILED) {
|
||||||
m_activity.login(true);
|
m_activity.login(true);
|
||||||
} else {
|
} else {
|
||||||
m_activity.toast(getErrorMessage());
|
|
||||||
|
if (m_lastErrorMessage != null) {
|
||||||
|
m_activity.toast(getString(getErrorMessage()) + "\n" + m_lastErrorMessage);
|
||||||
|
} else {
|
||||||
|
m_activity.toast(getErrorMessage());
|
||||||
|
}
|
||||||
|
|
||||||
//m_activity.setLoadingStatus(getErrorMessage(), false);
|
//m_activity.setLoadingStatus(getErrorMessage(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -570,7 +570,13 @@ public class FeedsFragment extends BaseFeedlistFragment implements OnItemClickLi
|
|||||||
if (m_lastError == ApiError.LOGIN_FAILED) {
|
if (m_lastError == ApiError.LOGIN_FAILED) {
|
||||||
m_activity.login(true);
|
m_activity.login(true);
|
||||||
} else {
|
} else {
|
||||||
m_activity.toast(getErrorMessage());
|
|
||||||
|
if (m_lastErrorMessage != null) {
|
||||||
|
m_activity.toast(getString(getErrorMessage()) + "\n" + m_lastErrorMessage);
|
||||||
|
} else {
|
||||||
|
m_activity.toast(getErrorMessage());
|
||||||
|
}
|
||||||
|
|
||||||
//m_activity.setLoadingStatus(getErrorMessage(), false);
|
//m_activity.setLoadingStatus(getErrorMessage(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -565,7 +565,13 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
if (m_lastError == ApiError.LOGIN_FAILED) {
|
if (m_lastError == ApiError.LOGIN_FAILED) {
|
||||||
m_activity.login(true);
|
m_activity.login(true);
|
||||||
} else {
|
} else {
|
||||||
m_activity.toast(getErrorMessage());
|
|
||||||
|
if (m_lastErrorMessage != null) {
|
||||||
|
m_activity.toast(getString(getErrorMessage()) + "\n" + m_lastErrorMessage);
|
||||||
|
} else {
|
||||||
|
m_activity.toast(getErrorMessage());
|
||||||
|
}
|
||||||
|
|
||||||
//m_activity.setLoadingStatus(getErrorMessage(), false);
|
//m_activity.setLoadingStatus(getErrorMessage(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1148,6 +1148,20 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setLoadingStatus(String status, boolean showProgress) {
|
||||||
|
TextView tv = (TextView) findViewById(R.id.loading_message);
|
||||||
|
|
||||||
|
if (tv != null) {
|
||||||
|
tv.setText(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
View loadingContainer = findViewById(R.id.loading_container);
|
||||||
|
|
||||||
|
if (loadingContainer != null) {
|
||||||
|
loadingContainer.setVisibility(status.equals("") ? View.GONE : View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void logout() {
|
protected void logout() {
|
||||||
setSessionId(null);
|
setSessionId(null);
|
||||||
|
|
||||||
@ -1628,6 +1642,12 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
|
|
||||||
setLoadingStatus(getErrorMessage(), false);
|
setLoadingStatus(getErrorMessage(), false);
|
||||||
|
|
||||||
|
if (m_lastErrorMessage != null) {
|
||||||
|
setLoadingStatus(getString(getErrorMessage()) + "\n\n" + m_lastErrorMessage, false);
|
||||||
|
} else {
|
||||||
|
setLoadingStatus(getErrorMessage(), false);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_listener != null) {
|
if (m_listener != null) {
|
||||||
m_listener.OnLoginFailed();
|
m_listener.OnLoginFailed();
|
||||||
} else {
|
} else {
|
||||||
@ -1667,7 +1687,12 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setSessionId(null);
|
setSessionId(null);
|
||||||
setLoadingStatus(getErrorMessage(), false);
|
|
||||||
|
if (m_lastErrorMessage != null) {
|
||||||
|
setLoadingStatus(getString(getErrorMessage()) + "\n\n" + m_lastErrorMessage, false);
|
||||||
|
} else {
|
||||||
|
setLoadingStatus(getErrorMessage(), false);
|
||||||
|
}
|
||||||
|
|
||||||
loginFailure();
|
loginFailure();
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,12 @@ public class HeadlinesRequest extends ApiRequest {
|
|||||||
if (m_lastError == ApiError.LOGIN_FAILED) {
|
if (m_lastError == ApiError.LOGIN_FAILED) {
|
||||||
m_activity.login();
|
m_activity.login();
|
||||||
} else {
|
} else {
|
||||||
m_activity.toast(getErrorMessage());
|
|
||||||
|
if (m_lastErrorMessage != null) {
|
||||||
|
m_activity.toast(m_activity.getString(getErrorMessage()) + "\n" + m_lastErrorMessage);
|
||||||
|
} else {
|
||||||
|
m_activity.toast(getErrorMessage());
|
||||||
|
}
|
||||||
//m_activity.setLoadingStatus(getErrorMessage(), false);
|
//m_activity.setLoadingStatus(getErrorMessage(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user