From 8b6375f5ef97e770c9456eba5315e27437e6642a Mon Sep 17 00:00:00 2001 From: pvannierop Date: Wed, 27 Nov 2024 09:15:56 +0100 Subject: [PATCH] Add error message when reaching co-routine timeout for http requests --- .../jersey/coroutines/CoroutineRequestWrapper.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/radar-jersey/src/main/kotlin/org/radarbase/jersey/coroutines/CoroutineRequestWrapper.kt b/radar-jersey/src/main/kotlin/org/radarbase/jersey/coroutines/CoroutineRequestWrapper.kt index 4e168aa..dd0165c 100644 --- a/radar-jersey/src/main/kotlin/org/radarbase/jersey/coroutines/CoroutineRequestWrapper.kt +++ b/radar-jersey/src/main/kotlin/org/radarbase/jersey/coroutines/CoroutineRequestWrapper.kt @@ -44,7 +44,12 @@ class CoroutineRequestWrapper( timeout ?: return launch { delay(timeout) - emit(HttpServerUnavailableException()) + emit( + HttpServerUnavailableException( + "The co-routine that handles the request exceeded the max duration of " + + "$timeout. The request timeout can be configured as parameter to the runAsCoroutine() or runBlocking() function." + ) + ) } } @@ -63,7 +68,10 @@ data class CoroutineRequestConfig( var location: String? = null, ) -fun CoroutineRequestWrapper(requestScope: RequestScope? = null, block: CoroutineRequestConfig.(hasExistingScope: Boolean) -> Unit): CoroutineRequestWrapper { +fun CoroutineRequestWrapper( + requestScope: RequestScope? = null, + block: CoroutineRequestConfig.(hasExistingScope: Boolean) -> Unit, +): CoroutineRequestWrapper { var newlyCreated = false val requestContext = try { if (requestScope != null) {