aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules/kvision-remote/src
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2019-11-01 17:44:31 +0100
committerRobert Jaros <rjaros@finn.pl>2019-11-01 17:44:31 +0100
commit5763aa3b0004b678d7791b32e1a92b6facb9b17e (patch)
tree3bd6ca99f2f2dbec9e196ca63215c7ba4bce6603 /kvision-modules/kvision-remote/src
parentc4a43b9c8ce6db65784e9bcb7073dcf6c4a6cd41 (diff)
downloadkvision-5763aa3b0004b678d7791b32e1a92b6facb9b17e.tar.gz
kvision-5763aa3b0004b678d7791b32e1a92b6facb9b17e.tar.bz2
kvision-5763aa3b0004b678d7791b32e1a92b6facb9b17e.zip
Better exception handling in server-side interfaces.
Diffstat (limited to 'kvision-modules/kvision-remote/src')
-rw-r--r--kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt8
1 files changed, 7 insertions, 1 deletions
diff --git a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt
index 64c257cd..0a56465d 100644
--- a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt
+++ b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt
@@ -71,7 +71,13 @@ open class CallAgent {
{ data: dynamic, _: Any, _: Any ->
when {
data.id != jsonRpcRequest.id -> reject(Exception("Invalid response ID"))
- data.error != null -> reject(Exception(data.error.toString()))
+ data.error != null -> {
+ if (data.exceptionType == "pl.treksoft.kvision.remote.ServiceException") {
+ reject(ServiceException(data.error.toString()))
+ } else {
+ reject(Exception(data.error.toString()))
+ }
+ }
data.result != null -> resolve(data.result)
else -> reject(Exception("Invalid response"))
}