Exception when the player name is null
Closed this issue · 0 comments
gloomy-ghost commented
The user input for player name is not validated, and an exception is raised when there is no input at all. Is there a neat way to specify the EditText field as required?
05-20 01:47:19.860 3828-5197/org.secuso.privacyfriendlycardgameone D/WebsocketClientHandler: onStringAvailable: {players=[{isDead=false, name=, playerId=0.0, playerRole=WEREWOLF}, {isDead=false, name=client, playerId=4.6020915996841083E18, playerRole=WITCH}], settings={TIME_VILLAGER=300, TIME_WEREWOLF=60, TIME_SEER=60, TIME_WITCH=60}}
05-20 01:47:19.875 3828-5197/org.secuso.privacyfriendlycardgameone D/GameContext: GameContext singleton created
05-20 01:47:19.885 3828-5197/org.secuso.privacyfriendlycardgameone E/NIO: Unhandled exception
com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unexpected value at line 1 column 32 path $.players[0].name
at com.google.gson.Gson.fromJson(Gson.java:902)
at com.google.gson.Gson.fromJson(Gson.java:852)
at com.google.gson.Gson.fromJson(Gson.java:801)
at com.google.gson.Gson.fromJson(Gson.java:773)
at org.secuso.privacyfriendlywerwolf.client.WebsocketClientHandler$1$2$override.onStringAvailable(WebsocketClientHandler.java:98)
at org.secuso.privacyfriendlywerwolf.client.WebsocketClientHandler$1$2$override.access$dispatch(Unknown Source:52)
at org.secuso.privacyfriendlywerwolf.client.WebsocketClientHandler$1$2.onStringAvailable(Unknown Source:15)
at com.koushikdutta.async.http.WebSocketImpl$1.onMessage(WebSocketImpl.java:88)
at com.koushikdutta.async.http.HybiParser.emitFrame(HybiParser.java:426)
at com.koushikdutta.async.http.HybiParser.access$800(HybiParser.java:48)
at com.koushikdutta.async.http.HybiParser$5.onDataAvailable(HybiParser.java:199)
at com.koushikdutta.async.DataEmitterReader.handlePendingData(DataEmitterReader.java:24)
at com.koushikdutta.async.DataEmitterReader.onDataAvailable(DataEmitterReader.java:41)
at com.koushikdutta.async.Util.emitAllData(Util.java:23)
at com.koushikdutta.async.AsyncNetworkSocket.onReadable(AsyncNetworkSocket.java:152)
at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:821)
at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:658)
at com.koushikdutta.async.AsyncServer.access$800(AsyncServer.java:44)
at com.koushikdutta.async.AsyncServer$14.run(AsyncServer.java:600)
Caused by: com.google.gson.stream.MalformedJsonException: Unexpected value at line 1 column 32 path $.players[0].name
at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1559)
at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:564)
at com.google.gson.stream.JsonReader.peek(JsonReader.java:425)
at com.google.gson.internal.bind.TypeAdapters$16.read(TypeAdapters.java:409)
at com.google.gson.internal.bind.TypeAdapters$16.read(TypeAdapters.java:406)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220)
at com.google.gson.Gson.fromJson(Gson.java:887)
at com.google.gson.Gson.fromJson(Gson.java:852)
at com.google.gson.Gson.fromJson(Gson.java:801)
at com.google.gson.Gson.fromJson(Gson.java:773)
at org.secuso.privacyfriendlywerwolf.client.WebsocketClientHandler$1$2$override.onStringAvailable(WebsocketClientHandler.java:98)
at org.secuso.privacyfriendlywerwolf.client.WebsocketClientHandler$1$2$override.access$dispatch(Unknown Source:52)
at org.secuso.privacyfriendlywerwolf.client.WebsocketClientHandler$1$2.onStringAvailable(Unknown Source:15)
at com.koushikdutta.async.http.WebSocketImpl$1.onMessage(WebSocketImpl.java:88)
at com.koushikdutta.async.http.HybiParser.emitFrame(HybiParser.java:426)
at com.koushikdutta.async.http.HybiParser.access$800(HybiParser.java:48)
at com.koushikdutta.async.http.HybiParser$5.onDataAvailable(HybiParser.java:199)
at com.koushikdutta.async.DataEmitterReader.handlePendingData(DataEmitterReader.java:24)
at com.koushikdutta.async.DataEmitterReader.onDataAvailable(DataEmitterReader.java:41)
at com.koushikdutta.async.Util.emitAllData(Util.java:23)
at com.koushikdutta.async.AsyncNetworkSocket.onReadable(AsyncNetworkSocket.java:152)
at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:821)
at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:658)
at com.koushikdutta.async.AsyncServer.access$800(AsyncServer.java:44)
at com.koushikdutta.async.AsyncServer$14.run(AsyncServer.java:600)