|
1 | 1 | package io.github.freya022.botcommands.internal.components.controller |
2 | 2 |
|
3 | 3 | import io.github.freya022.botcommands.api.components.annotations.RequiresComponents |
| 4 | +import io.github.freya022.botcommands.api.components.exceptions.ComponentTimeoutException |
4 | 5 | import io.github.freya022.botcommands.api.core.BContext |
5 | 6 | import io.github.freya022.botcommands.api.core.service.ServiceContainer |
6 | 7 | import io.github.freya022.botcommands.api.core.service.annotations.BService |
7 | 8 | import io.github.freya022.botcommands.api.core.service.lazy |
8 | 9 | import io.github.freya022.botcommands.internal.components.handler.ComponentTimeoutExecutor |
9 | 10 | import io.github.freya022.botcommands.internal.components.repositories.ComponentRepository |
10 | 11 | import io.github.freya022.botcommands.internal.core.ExceptionHandler |
11 | | -import io.github.freya022.botcommands.internal.utils.TimeoutExceptionAccessor |
12 | 12 | import io.github.oshai.kotlinlogging.KotlinLogging |
13 | 13 | import kotlinx.coroutines.CancellationException |
14 | 14 | import kotlinx.coroutines.Job |
@@ -66,13 +66,11 @@ internal class ComponentTimeoutManager( |
66 | 66 | if (continuations.isEmpty()) return |
67 | 67 |
|
68 | 68 | // Continuations must be canceled |
69 | | - if (throwTimeouts) { |
70 | | - val timeoutException = TimeoutExceptionAccessor.createComponentTimeoutException() |
71 | | - continuations.forEach { it.cancel(timeoutException) } |
72 | | - } else { |
73 | | - val cancellationException = CancellationException("Component was deleted") |
74 | | - continuations.forEach { it.cancel(cancellationException) } |
| 69 | + val exception = when { |
| 70 | + throwTimeouts -> ComponentTimeoutException("Timed out waiting for component") |
| 71 | + else -> CancellationException("Component was deleted") |
75 | 72 | } |
| 73 | + continuations.forEach { it.cancel(exception) } |
76 | 74 | } |
77 | 75 |
|
78 | 76 | internal fun cancelTimeout(componentId: Int) { |
|
0 commit comments