Skip to content

Commit

Permalink
send error message when execution fails
Browse files Browse the repository at this point in the history
  • Loading branch information
kukume committed Sep 4, 2024
1 parent d6af504 commit 0fd0fb6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/kotlin/me/kuku/telegram/context/Async.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ suspend fun <T : BaseRequest<T, R>, R : BaseResponse> TelegramBot.asyncExecute(r
val completableDeferred = CompletableDeferred<R>()
this.execute(request, object: Callback<T, R> {
override fun onResponse(request: T, response: R) {
completableDeferred.complete(response)
if (response.isOk) {
completableDeferred.complete(response)
} else {
completableDeferred.completeExceptionally(IllegalStateException(response.description()))
}
}

override fun onFailure(request: T, e: IOException) {
Expand Down

0 comments on commit 0fd0fb6

Please sign in to comment.