diff options
author | Robert Jaros <rjaros@finn.pl> | 2019-11-01 17:44:31 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2019-11-01 17:44:31 +0100 |
commit | 5763aa3b0004b678d7791b32e1a92b6facb9b17e (patch) | |
tree | 3bd6ca99f2f2dbec9e196ca63215c7ba4bce6603 /kvision-modules/kvision-server-jooby/src | |
parent | c4a43b9c8ce6db65784e9bcb7073dcf6c4a6cd41 (diff) | |
download | kvision-5763aa3b0004b678d7791b32e1a92b6facb9b17e.tar.gz kvision-5763aa3b0004b678d7791b32e1a92b6facb9b17e.tar.bz2 kvision-5763aa3b0004b678d7791b32e1a92b6facb9b17e.zip |
Better exception handling in server-side interfaces.
Diffstat (limited to 'kvision-modules/kvision-server-jooby/src')
-rw-r--r-- | kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt b/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt index bb682351..d81dc7a7 100644 --- a/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt +++ b/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt @@ -106,8 +106,9 @@ actual open class KVServiceManager<T : Any> actual constructor(val serviceClass: ) ) } catch (e: Exception) { - LOG.error(e.message, e) - res.send(JsonRpcResponse(id = jsonRpcRequest.id, error = e.message ?: "Error")) + if (!(e is ServiceException)) LOG.error(e.message, e) + res.send(JsonRpcResponse(id = jsonRpcRequest.id, error = e.message ?: "Error", + exceptionType = e.javaClass.canonicalName)) } } }.invoke(this) @@ -145,8 +146,9 @@ actual open class KVServiceManager<T : Any> actual constructor(val serviceClass: ) ) } catch (e: Exception) { - LOG.error(e.message, e) - res.send(JsonRpcResponse(id = jsonRpcRequest.id, error = e.message ?: "Error")) + if (!(e is ServiceException)) LOG.error(e.message, e) + res.send(JsonRpcResponse(id = jsonRpcRequest.id, error = e.message ?: "Error", + exceptionType = e.javaClass.canonicalName)) } } } else { @@ -188,8 +190,9 @@ actual open class KVServiceManager<T : Any> actual constructor(val serviceClass: ) ) } catch (e: Exception) { - LOG.error(e.message, e) - res.send(JsonRpcResponse(id = jsonRpcRequest.id, error = e.message ?: "Error")) + if (!(e is ServiceException)) LOG.error(e.message, e) + res.send(JsonRpcResponse(id = jsonRpcRequest.id, error = e.message ?: "Error", + exceptionType = e.javaClass.canonicalName)) } } } else { @@ -233,8 +236,9 @@ actual open class KVServiceManager<T : Any> actual constructor(val serviceClass: ) ) } catch (e: Exception) { - LOG.error(e.message, e) - res.send(JsonRpcResponse(id = jsonRpcRequest.id, error = e.message ?: "Error")) + if (!(e is ServiceException)) LOG.error(e.message, e) + res.send(JsonRpcResponse(id = jsonRpcRequest.id, error = e.message ?: "Error", + exceptionType = e.javaClass.canonicalName)) } } } else { @@ -279,8 +283,9 @@ actual open class KVServiceManager<T : Any> actual constructor(val serviceClass: ) ) } catch (e: Exception) { - LOG.error(e.message, e) - res.send(JsonRpcResponse(id = jsonRpcRequest.id, error = e.message ?: "Error")) + if (!(e is ServiceException)) LOG.error(e.message, e) + res.send(JsonRpcResponse(id = jsonRpcRequest.id, error = e.message ?: "Error", + exceptionType = e.javaClass.canonicalName)) } } } else { @@ -327,8 +332,9 @@ actual open class KVServiceManager<T : Any> actual constructor(val serviceClass: ) ) } catch (e: Exception) { - LOG.error(e.message, e) - res.send(JsonRpcResponse(id = jsonRpcRequest.id, error = e.message ?: "Error")) + if (!(e is ServiceException)) LOG.error(e.message, e) + res.send(JsonRpcResponse(id = jsonRpcRequest.id, error = e.message ?: "Error", + exceptionType = e.javaClass.canonicalName)) } } } else { @@ -440,8 +446,9 @@ actual open class KVServiceManager<T : Any> actual constructor(val serviceClass: ) ) } catch (e: Exception) { - LOG.error(e.message, e) - res.send(JsonRpcResponse(id = jsonRpcRequest.id, error = e.message ?: "Error")) + if (!(e is ServiceException)) LOG.error(e.message, e) + res.send(JsonRpcResponse(id = jsonRpcRequest.id, error = e.message ?: "Error", + exceptionType = e.javaClass.canonicalName)) } } } else { @@ -482,8 +489,9 @@ actual open class KVServiceManager<T : Any> actual constructor(val serviceClass: ) ) } catch (e: Exception) { - LOG.error(e.message, e) - res.send(JsonRpcResponse(id = jsonRpcRequest.id, error = e.message ?: "Error")) + if (!(e is ServiceException)) LOG.error(e.message, e) + res.send(JsonRpcResponse(id = jsonRpcRequest.id, error = e.message ?: "Error", + exceptionType = e.javaClass.canonicalName)) } } } else { |