Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d676184

Browse files
committed
add log in exception handling.
1 parent 49e6bf4 commit d676184

File tree

1 file changed

+11
-2
lines changed
  • controller-application/Police/app/src/main/java/io/github/xei/police/joystick

1 file changed

+11
-2
lines changed

‎controller-application/Police/app/src/main/java/io/github/xei/police/joystick/JoystickFragment.kt‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ import java.io.OutputStream
2222
import java.util.*
2323
import android.content.ComponentName
2424
import android.os.Message
25+
import android.util.Log
2526
import com.google.gson.Gson
27+
import com.google.gson.stream.MalformedJsonException
2628
import io.github.xei.police.app.Action
2729
import io.github.xei.police.app.State
2830
import java.io.IOException
@@ -36,6 +38,8 @@ import java.io.IOException
3638
class JoystickFragment : Fragment(), JoystickContract.View, View.OnClickListener {
3739

3840
companion object {
41+
private const val TAG_DEBUG = "JoystickFragment"
42+
3943
private const val REQUEST_CODE_ENABLE_BLUETOOTH = 100
4044
private const val REQUEST_CODE_SPEECH_RECOGNIZE = 200
4145

@@ -189,8 +193,13 @@ class JoystickFragment : Fragment(), JoystickContract.View, View.OnClickListener
189193
val msg = Message.obtain()
190194
msg.obj = s
191195
activity?.runOnUiThread {
192-
val sensorsState = mGson.fromJson(s, State::class.java)
193-
presenter.makePolicy(sensorsState)
196+
try {
197+
val sensorsState = mGson.fromJson(s, State::class.java)
198+
presenter.makePolicy(sensorsState)
199+
} catch (mje: MalformedJsonException) {
200+
Log.e(TAG_DEBUG, "MalformedJson: $s")
201+
}
202+
194203
}
195204

196205
// Look for more complete messages

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /