siramix/buzzwords

Crash on JSON parse exception

lucasrowe opened this issue · 1 comments

We need to properly handle JSON parse exception for pack data.

  1. App should not crash.
  2. App should just behave as if purchase server could not be reached.

D/PackParser(11188): --> { "_id": 200, "name" : "Winter Holidays", "path" : "packs/winter_holidays.json", "icon_path": "packs/icons/packicon_christmas.png", "description" : "Celebrate the holiday season with this festive set of wintery words.", "size" : 250, "purchase_type" : 1, "version" : 18, "price" : "$0.99"}
I/AmazonSDKTester( 9067): Sending UserId Response Broadcast ({"status":"SUCCESSFUL","requestId":"c3af3242-4ea3-401e-a367-7ec32f93210a","userId":"fsg"})
D/Pack (11188): constructor Pack(args)
D/PackParser(11188): stringToPack
D/PackParser(11188): -->
E/PackPurchase(11188): Error parsing pack JSON from server.
W/dalvikvm(11188): threadid=15: thread exiting with uncaught exception (group=0x41bfb300)
E/AndroidRuntime(11188): FATAL EXCEPTION: Thread-862
E/AndroidRuntime(11188): android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
E/AndroidRuntime(11188): at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:4607)
E/AndroidRuntime(11188): at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:835)
E/AndroidRuntime(11188): at android.view.View.requestLayout(View.java:15129)
E/AndroidRuntime(11188): at android.view.View.requestLayout(View.java:15129)
E/AndroidRuntime(11188): at android.view.View.requestLayout(View.java:15129)
E/AndroidRuntime(11188): at android.view.View.requestLayout(View.java:15129)
E/AndroidRuntime(11188): at android.view.View.requestLayout(View.java:15129)
E/AndroidRuntime(11188): at android.widget.ScrollView.requestLayout(ScrollView.java:1419)
E/AndroidRuntime(11188): at android.view.View.requestLayout(View.java:15129)
E/AndroidRuntime(11188): at android.view.View.requestLayout(View.java:15129)
E/AndroidRuntime(11188): at android.widget.TextView.checkForRelayout(TextView.java:6309)
E/AndroidRuntime(11188): at android.widget.TextView.setText(TextView.java:3547)
E/AndroidRuntime(11188): at android.widget.TextView.setText(TextView.java:3405)
E/AndroidRuntime(11188): at android.widget.TextView.setText(TextView.java:3380)
E/AndroidRuntime(11188): at com.buzzwords.PackPurchaseActivity$5.run(PackPurchaseActivity.java:292)
W/ActivityManager( 288): Force finishing activity com.buzzwords/.PackPurchaseActivity
W/ActivityManager( 288): Force finishing activity com.buzzwords/.TitleActivity

Commit f0d2421 should fix this.