Skip to content
This repository has been archived by the owner on Aug 22, 2022. It is now read-only.

Commit

Permalink
Catch obscure inner exceptions from xml serializer and continue
Browse files Browse the repository at this point in the history
  • Loading branch information
loopj committed Jun 14, 2011
1 parent 26b9229 commit 2e4df5c
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions src/com/loopj/android/hoptoad/HoptoadNotifier.java
Expand Up @@ -212,22 +212,25 @@ private static void writeExceptionToDisk(Throwable e) {
s.startTag("", "backtrace");
Throwable currentEx = e;
while(currentEx != null) {
StackTraceElement[] stackTrace = currentEx.getStackTrace();
for(StackTraceElement el : stackTrace) {
s.startTag("", "line");
s.attribute("", "method", el.getClassName() + "." + el.getMethodName());
s.attribute("", "file", el.getFileName());
s.attribute("", "number", String.valueOf(el.getLineNumber()));
s.endTag("", "line");
}

currentEx = currentEx.getCause();
if(currentEx != null) {
s.startTag("", "line");
s.attribute("", "file", "### CAUSED BY ###: " + currentEx.toString());
s.attribute("", "number", "");
s.endTag("", "line");
}
// Catch some inner exceptions without discarding the entire report
try {
StackTraceElement[] stackTrace = currentEx.getStackTrace();
for(StackTraceElement el : stackTrace) {
s.startTag("", "line");
s.attribute("", "method", el.getClassName() + "." + el.getMethodName());
s.attribute("", "file", el.getFileName());
s.attribute("", "number", String.valueOf(el.getLineNumber()));
s.endTag("", "line");
}

currentEx = currentEx.getCause();
if(currentEx != null) {
s.startTag("", "line");
s.attribute("", "file", "### CAUSED BY ###: " + currentEx.toString());
s.attribute("", "number", "");
s.endTag("", "line");
}
} catch(Throwable innerException) {}
}
s.endTag("", "backtrace");
s.endTag("", "error");
Expand Down

0 comments on commit 2e4df5c

Please sign in to comment.