Skip to content

Commit

Permalink
Add error message when reaching co-routine timeout for http requests
Browse files Browse the repository at this point in the history
  • Loading branch information
pvannierop committed Nov 27, 2024
1 parent 20a5ee1 commit 8b6375f
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)
)
}
}

Expand All @@ -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) {
Expand Down

0 comments on commit 8b6375f

Please sign in to comment.