File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed
src/main/kotlin/dev/fruxz/brigadikt/structure Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change 11package dev.fruxz.brigadikt.structure
22
3- import dev.fruxz.ascend.extension.tryOrNull
43import dev.fruxz.brigadikt.CommandContext
54import dev.fruxz.brigadikt.DefaultProvider
65import kotlin.reflect.KMutableProperty
@@ -14,13 +13,14 @@ open class ArgumentProvider<I : Any, O>(
1413 val processor : Processor <I , O >,
1514) {
1615
17- open fun resolve (context : CommandContext ): O =
18- tryOrNull {
19- processor.perform(
20- context = context,
21- input = lazyArgument(name ? : throw IllegalStateException (" name not yet present in ArgumentProvider" )).resolve(context)
22- )
23- } ? : default?.provide(context) ? : throw IllegalStateException (" Failed to resolve ArgumentProvider" )
16+ open fun resolve (context : CommandContext ): O = try {
17+ processor.perform(
18+ context = context,
19+ input = lazyArgument(name ? : throw IllegalStateException (" name (of the argument) not yet present in ArgumentProvider" )).resolve(context)
20+ )
21+ } catch (e: Exception ) {
22+ default?.provide(context) ? : throw e
23+ }
2424
2525 /* *
2626 * Drops the default again, since its now not matching anymore
You can’t perform that action at this time.
0 commit comments