From 5763aa3b0004b678d7791b32e1a92b6facb9b17e Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Fri, 1 Nov 2019 17:44:31 +0100 Subject: Better exception handling in server-side interfaces. --- .../pl/treksoft/kvision/remote/KVServiceManager.kt | 40 +++++++++++++--------- 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'kvision-modules/kvision-server-spring-boot') diff --git a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt index fb6b6210..17451461 100644 --- a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt +++ b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt @@ -146,12 +146,13 @@ actual open class KVServiceManager actual constructor(val serviceClass: ) ) } catch (e: Exception) { - LOG.error(e.message, e) + if (!(e is ServiceException)) LOG.error(e.message, e) ServerResponse.ok().json().bodyValueAndAwait( mapper.writeValueAsString( JsonRpcResponse( id = jsonRpcRequest.id, - error = e.message ?: "Error" + error = e.message ?: "Error", + exceptionType = e.javaClass.canonicalName ) ) ) @@ -190,12 +191,13 @@ actual open class KVServiceManager actual constructor(val serviceClass: ) ) } catch (e: Exception) { - LOG.error(e.message, e) + if (!(e is ServiceException)) LOG.error(e.message, e) ServerResponse.ok().json().bodyValueAndAwait( mapper.writeValueAsString( JsonRpcResponse( id = jsonRpcRequest.id, - error = e.message ?: "Error" + error = e.message ?: "Error", + exceptionType = e.javaClass.canonicalName ) ) ) @@ -245,12 +247,13 @@ actual open class KVServiceManager actual constructor(val serviceClass: ) ) } catch (e: Exception) { - LOG.error(e.message, e) + if (!(e is ServiceException)) LOG.error(e.message, e) ServerResponse.ok().json().bodyValueAndAwait( mapper.writeValueAsString( JsonRpcResponse( id = jsonRpcRequest.id, - error = e.message ?: "Error" + error = e.message ?: "Error", + exceptionType = e.javaClass.canonicalName ) ) ) @@ -302,12 +305,13 @@ actual open class KVServiceManager actual constructor(val serviceClass: ) ) } catch (e: Exception) { - LOG.error(e.message, e) + if (!(e is ServiceException)) LOG.error(e.message, e) ServerResponse.ok().json().bodyValueAndAwait( mapper.writeValueAsString( JsonRpcResponse( id = jsonRpcRequest.id, - error = e.message ?: "Error" + error = e.message ?: "Error", + exceptionType = e.javaClass.canonicalName ) ) ) @@ -360,12 +364,13 @@ actual open class KVServiceManager actual constructor(val serviceClass: ) ) } catch (e: Exception) { - LOG.error(e.message, e) + if (!(e is ServiceException)) LOG.error(e.message, e) ServerResponse.ok().json().bodyValueAndAwait( mapper.writeValueAsString( JsonRpcResponse( id = jsonRpcRequest.id, - error = e.message ?: "Error" + error = e.message ?: "Error", + exceptionType = e.javaClass.canonicalName ) ) ) @@ -420,12 +425,13 @@ actual open class KVServiceManager actual constructor(val serviceClass: ) ) } catch (e: Exception) { - LOG.error(e.message, e) + if (!(e is ServiceException)) LOG.error(e.message, e) ServerResponse.ok().json().bodyValueAndAwait( mapper.writeValueAsString( JsonRpcResponse( id = jsonRpcRequest.id, - error = e.message ?: "Error" + error = e.message ?: "Error", + exceptionType = e.javaClass.canonicalName ) ) ) @@ -530,12 +536,13 @@ actual open class KVServiceManager actual constructor(val serviceClass: ) ) } catch (e: Exception) { - LOG.error(e.message, e) + if (!(e is ServiceException)) LOG.error(e.message, e) ServerResponse.ok().json().bodyValueAndAwait( mapper.writeValueAsString( JsonRpcResponse( id = jsonRpcRequest.id, - error = e.message ?: "Error" + error = e.message ?: "Error", + exceptionType = e.javaClass.canonicalName ) ) ) @@ -584,12 +591,13 @@ actual open class KVServiceManager actual constructor(val serviceClass: ) ) } catch (e: Exception) { - LOG.error(e.message, e) + if (!(e is ServiceException)) LOG.error(e.message, e) ServerResponse.ok().json().bodyValueAndAwait( mapper.writeValueAsString( JsonRpcResponse( id = jsonRpcRequest.id, - error = e.message ?: "Error" + error = e.message ?: "Error", + exceptionType = e.javaClass.canonicalName ) ) ) -- cgit