improve exceptions
This commit is contained in:
@@ -20,7 +20,7 @@ sealed class Command private constructor(
|
||||
internal val renderer: HelpRenderer,
|
||||
) {
|
||||
init {
|
||||
if (!name.matches(Regex.COMMAND)) throw InvalidCommand(name)
|
||||
if (!name.matches(Regex.COMMAND)) throw InvalidCommandName(name)
|
||||
}
|
||||
|
||||
fun run(args: Array<String>) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.infendro.cli.command.argument
|
||||
|
||||
import com.infendro.cli.error.build.InvalidArgument
|
||||
import com.infendro.cli.error.build.InvalidArgumentName
|
||||
import com.infendro.cli.error.build.InvalidRange
|
||||
import com.infendro.cli.parser.Parser
|
||||
import com.infendro.cli.util.Regex.ARGUMENT
|
||||
@@ -13,7 +13,7 @@ sealed class Argument<T : Any>(
|
||||
) {
|
||||
init {
|
||||
when {
|
||||
!name.matches(ARGUMENT) -> throw InvalidArgument(name)
|
||||
!name.matches(ARGUMENT) -> throw InvalidArgumentName(name)
|
||||
min !in 0..count || max == 0 -> throw InvalidRange()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.infendro.cli.command.option
|
||||
|
||||
import com.infendro.cli.error.build.InvalidOption
|
||||
import com.infendro.cli.error.build.InvalidOptionName
|
||||
import com.infendro.cli.error.build.InvalidRange
|
||||
import com.infendro.cli.error.build.MissingOptionName
|
||||
import com.infendro.cli.parser.Parser
|
||||
@@ -35,7 +35,7 @@ sealed class Option<T : Any>(
|
||||
init {
|
||||
when {
|
||||
names.isEmpty() -> throw MissingOptionName()
|
||||
names.any { !it.matches(OPTION) } -> throw InvalidOption(name)
|
||||
names.any { !it.matches(OPTION) } -> throw InvalidOptionName(name)
|
||||
min !in 0..count || max == 0 -> throw InvalidRange()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user