Skip to content

Commit a2ce1e9

Browse files
committed
review method throwableToString to print all StackTrace and fix NPE in t.getMessage().toString()
1 parent 90ea903 commit a2ce1e9

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

sample/main/src/com/loopj/android/http/sample/SampleParentActivity.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package com.loopj.android.http.sample;
22

3-
import java.util.Locale;
3+
import java.io.PrintWriter;
4+
import java.io.StringWriter;
5+
6+
import org.apache.http.Header;
47

58
import android.app.Activity;
69
import android.graphics.Color;
@@ -18,8 +21,6 @@
1821
import com.loopj.android.http.AsyncHttpClient;
1922
import com.loopj.android.http.AsyncHttpResponseHandler;
2023

21-
import org.apache.http.Header;
22-
2324
public abstract class SampleParentActivity extends Activity {
2425

2526
private LinearLayout headers; // Sample header, inputs and buttons
@@ -101,7 +102,10 @@ protected final void debugHeaders(String TAG, Header[] headers) {
101102
protected static String throwableToString(Throwable t) {
102103
if (t == null)
103104
return null;
104-
return t.getMessage().toString();
105+
106+
StringWriter sw = new StringWriter();
107+
t.printStackTrace(new PrintWriter(sw));
108+
return sw.toString();
105109
}
106110

107111
protected final void debugThrowable(String TAG, Throwable t) {

0 commit comments

Comments
 (0)