Skip to content

Commit

Permalink
Show complete error message when lists fail to load
Browse files Browse the repository at this point in the history
click on the list to view the details. Useful for tracking down SSL errors
  • Loading branch information
mhagander committed Aug 15, 2012
1 parent 9d01ea8 commit bad59e9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/net/hagander/mailinglistmoderator/MailinglistModerator.java
Expand Up @@ -14,6 +14,7 @@

import net.hagander.mailinglistmoderator.backend.ListServer;
import net.hagander.mailinglistmoderator.glue.ListServerAdapter;
import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.Intent;
import android.content.SharedPreferences;
Expand Down Expand Up @@ -63,6 +64,15 @@ public void onCreate(Bundle savedInstanceState) {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
ListServer s = serverAdapter.getItem(position);
if (s.isExceptioned()) {
/* Show the complete error message */
new AlertDialog.Builder(MailinglistModerator.this)
.setTitle("Failed to load")
.setMessage(String.format("This list failed to load with the following exception:\n\n%s", s.getStatus()))
.setPositiveButton("Ok", null)
.show();
return;
}
if (!s.isPopulated())
return;

Expand Down
16 changes: 13 additions & 3 deletions src/net/hagander/mailinglistmoderator/backend/ListServer.java
Expand Up @@ -142,6 +142,16 @@ public boolean isPopulated() {
return populated;
}

/**
* Check if an exception has occurred when processing this list.
*
* @return if the list is exceptioned.
*/
public boolean isExceptioned() {
// TODO Auto-generated method stub
return exceptioned;
}

/**
* Get all messages in the moderation queue on the list.
*
Expand Down Expand Up @@ -174,7 +184,7 @@ public void Populate() {
}
catch (RuntimeException e) {
this.exceptioned = true;
this.status = String.format("%s", e);
this.status = String.format("%s", e.getMessage());
throw e;
}
}
Expand Down Expand Up @@ -238,10 +248,10 @@ protected String FetchUrl(String url) {
return sw.toString();
} catch (MalformedURLException e) {
throw new RuntimeException(String.format(
"Failed to fetch url %s: %s", url, e));
"Failed to fetch url: %s (%s)", e, url));
} catch (IOException e) {
throw new RuntimeException(String.format(
"Failed to fetch url %s: %s", url, e));
"Failed to fetch url: %s (%s)", e, url));
}
}

Expand Down

0 comments on commit bad59e9

Please sign in to comment.