mirror of
https://github.com/corda/corda.git
synced 2025-04-07 19:34:41 +00:00
Shell: more aggressive catch/rethrow of errors during command line parse. Avoids stack traces being dumped to the console when an unknown party name is provided.
This commit is contained in:
parent
aed9495b37
commit
922a760a09
@ -146,11 +146,12 @@ open class StringToMethodCallParser<in T : Any> @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
open class UnparseableCallException(command: String) : Exception("Could not parse as a command: $command") {
|
||||
open class UnparseableCallException(command: String, cause: Throwable? = null) : Exception("Could not parse as a command: $command", cause) {
|
||||
class UnknownMethod(val methodName: String) : UnparseableCallException("Unknown command name: $methodName")
|
||||
class MissingParameter(methodName: String, val paramName: String, command: String) : UnparseableCallException("Parameter $paramName missing from attempt to invoke $methodName in command: $command")
|
||||
class TooManyParameters(methodName: String, command: String) : UnparseableCallException("Too many parameters provided for $methodName: $command")
|
||||
class ReflectionDataMissing(methodName: String, argIndex: Int) : UnparseableCallException("Method $methodName missing parameter name at index $argIndex")
|
||||
class FailedParse(e: Exception) : UnparseableCallException(e.message ?: e.toString(), e)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -195,7 +196,11 @@ open class StringToMethodCallParser<in T : Any> @JvmOverloads constructor(
|
||||
val inOrderParams: List<Any?> = parameters.mapIndexed { _, param ->
|
||||
val (argName, argType) = param
|
||||
val entry = tree[argName] ?: throw UnparseableCallException.MissingParameter(methodNameHint, argName, args)
|
||||
om.readValue(entry.traverse(om), argType)
|
||||
try {
|
||||
om.readValue(entry.traverse(om), argType)
|
||||
} catch(e: Exception) {
|
||||
throw UnparseableCallException.FailedParse(e)
|
||||
}
|
||||
}
|
||||
if (log.isDebugEnabled) {
|
||||
inOrderParams.forEachIndexed { i, param ->
|
||||
|
@ -1,6 +1,6 @@
|
||||
package net.corda.node.shell;
|
||||
|
||||
// A simple forwarded to the "flow start" command, for easier typing.
|
||||
// A simple forwarder to the "flow start" command, for easier typing.
|
||||
|
||||
import org.crsh.cli.*;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user