Skip to content

Commit bfd2490

Browse files
committed
modals: Replace TimeoutCancellationException by ModalTimeoutException
1 parent cbfa6b0 commit bfd2490

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

BotCommands-core/src/main/java/io/github/freya022/botcommands/internal/utils/TimeoutExceptionAccessor.java

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package io.github.freya022.botcommands.api.modals.exceptions
2+
3+
import kotlinx.coroutines.CancellationException
4+
5+
/**
6+
* Exception thrown when modal timed out while a coroutine was awaiting a modal interaction
7+
*/
8+
class ModalTimeoutException(message: String) : CancellationException(message)

BotCommands-core/src/main/kotlin/io/github/freya022/botcommands/internal/modals/ModalMaps.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import io.github.freya022.botcommands.api.core.service.annotations.BService
77
import io.github.freya022.botcommands.api.modals.ModalEvent
88
import io.github.freya022.botcommands.api.modals.Modals
99
import io.github.freya022.botcommands.api.modals.annotations.RequiresModals
10+
import io.github.freya022.botcommands.api.modals.exceptions.ModalTimeoutException
1011
import io.github.freya022.botcommands.internal.core.ExceptionHandler
11-
import io.github.freya022.botcommands.internal.utils.TimeoutExceptionAccessor
1212
import io.github.freya022.botcommands.internal.utils.classRef
1313
import io.github.freya022.botcommands.internal.utils.throwInternal
1414
import io.github.oshai.kotlinlogging.KotlinLogging
@@ -62,7 +62,7 @@ internal class ModalMaps(context: BContext) {
6262
val data = modalLock.withLock { modalMap.remove(internalId) }
6363
if (data != null) { //If the timeout was reached without the modal being used
6464
if (data.continuations.isNotEmpty()) {
65-
val timeoutException = TimeoutExceptionAccessor.createModalTimeoutException()
65+
val timeoutException = ModalTimeoutException("Timed out waiting for modal")
6666
for (continuation in data.continuations) {
6767
continuation.cancel(timeoutException)
6868
}

0 commit comments

Comments
 (0)