diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt b/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt index 2f85a51f..7d9f4b05 100644 --- a/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt +++ b/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt @@ -59,14 +59,11 @@ open class CallAgent { this.method = method.name this.success = { data: dynamic, _: Any, _: Any -> - if (data.id != jsonRpcRequest.id) { - reject(Exception("Invalid response ID")) - } else if (data.error != null) { - reject(Exception(data.error.toString())) - } else if (data.result != null) { - resolve(data.result) - } else { - reject(Exception("Invalid response")) + when { + data.id != jsonRpcRequest.id -> reject(Exception("Invalid response ID")) + data.error != null -> reject(Exception(data.error.toString())) + data.result != null -> resolve(data.result) + else -> reject(Exception("Invalid response")) } } this.error = |