fix(driver-abcip-cli): resolve Medium code-review findings (Driver.AbCip.Cli-001, -002)
Driver.AbCip.Cli-001: WriteCommand.ParseValue wraps FormatException/ OverflowException as CommandException so bad --value input yields a clean CLI error instead of a raw stack trace. Driver.AbCip.Cli-002: probe/read/subscribe commands reject Structure types up front (RejectStructure helper), matching the write guard. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -56,4 +56,19 @@ public abstract class AbCipCommandBase : DriverCommandBase
|
||||
/// multiple gateways in parallel can distinguish the logs.
|
||||
/// </summary>
|
||||
protected string DriverInstanceId => $"abcip-cli-{Gateway}";
|
||||
|
||||
/// <summary>
|
||||
/// Guards against <see cref="AbCipDataType.Structure"/> being passed to a command
|
||||
/// that does not support UDT layouts. Call at the top of <c>ExecuteAsync</c> for any
|
||||
/// command that accepts <c>--type</c> but cannot handle memberless Structure tags.
|
||||
/// Throws a <see cref="CliFx.Exceptions.CommandException"/> if <paramref name="type"/>
|
||||
/// is <see cref="AbCipDataType.Structure"/>.
|
||||
/// </summary>
|
||||
protected static void RejectStructure(AbCipDataType type)
|
||||
{
|
||||
if (type == AbCipDataType.Structure)
|
||||
throw new CliFx.Exceptions.CommandException(
|
||||
"Structure (UDT) reads are out of scope for this command — those need an explicit " +
|
||||
"member layout, which belongs in a real driver config.");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user