diff --git a/core/src/com/unciv/logic/multiplayer/apiv2/ApiV2.kt b/core/src/com/unciv/logic/multiplayer/apiv2/ApiV2.kt index 1c6784bd17..cd796bb5d9 100644 --- a/core/src/com/unciv/logic/multiplayer/apiv2/ApiV2.kt +++ b/core/src/com/unciv/logic/multiplayer/apiv2/ApiV2.kt @@ -183,7 +183,7 @@ class ApiV2(private val baseUrl: String) : ApiV2Wrapper(baseUrl), Disposable { val b: VersionResponse = r.body() b.version == 2 } - } catch (e: IllegalArgumentException) { + } catch (_: IllegalArgumentException) { false } catch (e: Throwable) { Log.error("Unexpected exception calling version endpoint for '$baseUrl': $e") @@ -204,7 +204,7 @@ class ApiV2(private val baseUrl: String) : ApiV2Wrapper(baseUrl), Disposable { val b: ApiErrorResponse = r.body() b.statusCode == ApiStatusCode.Unauthenticated } - } catch (e: IllegalArgumentException) { + } catch (_: IllegalArgumentException) { false } catch (e: Throwable) { Log.error("Unexpected exception calling WebSocket endpoint for '$baseUrl': $e") @@ -339,9 +339,7 @@ class ApiV2(private val baseUrl: String) : ApiV2Wrapper(baseUrl), Disposable { * This function may also throw arbitrary exceptions for network failures. */ suspend fun awaitPing(size: Int = 2, timeout: Long? = null): Double? { - if (size < 2) { - throw IllegalArgumentException("Size too small to identify ping responses uniquely") - } + require(size < 2) { "Size too small to identify ping responses uniquely" } val body = ByteArray(size) Random().nextBytes(body) @@ -371,7 +369,7 @@ class ApiV2(private val baseUrl: String) : ApiV2Wrapper(baseUrl), Disposable { throw exception } }.toDouble() / 10e6 - } catch (c: ClosedReceiveChannelException) { + } catch (_: ClosedReceiveChannelException) { return null } finally { synchronized(this) { @@ -448,7 +446,7 @@ class ApiV2(private val baseUrl: String) : ApiV2Wrapper(baseUrl), Disposable { Concurrency.run { try { c.send((msg as WebSocketMessageWithContent).content) - } catch (closed: ClosedSendChannelException) { + } catch (_: ClosedSendChannelException) { delay(10) eventChannelList.remove(c) } catch (t: Throwable) { diff --git a/core/src/com/unciv/logic/multiplayer/storage/OnlineMultiplayerServer.kt b/core/src/com/unciv/logic/multiplayer/storage/OnlineMultiplayerServer.kt index 5d2a962932..98e9975b94 100644 --- a/core/src/com/unciv/logic/multiplayer/storage/OnlineMultiplayerServer.kt +++ b/core/src/com/unciv/logic/multiplayer/storage/OnlineMultiplayerServer.kt @@ -50,7 +50,7 @@ class OnlineMultiplayerServer( if (result.isNotEmpty()) { featureSet = try { json().fromJson(ServerFeatureSet::class.java, result) - } catch (ex: Exception) { + } catch (_: Exception) { // The server does not support server feature set - not an error! ServerFeatureSet() }