44// Licensed under the BSD 3-Clause license. See LICENSE file in the project root for full license information.
55// </copyright>
66
7+ using System . Linq ;
78using System . Threading ;
89using System . Threading . Tasks ;
910using Buttplug . Core ;
@@ -96,7 +97,13 @@ public async Task RunOutputAsync(DeviceOutputCommand command, CancellationToken
9697 {
9798 if ( ! HasOutput ( command . OutputType ) )
9899 {
99- throw new ButtplugDeviceException ( $ "Feature { FeatureIndex } on device { Device . Name } does not support output type { command . OutputType } ") ;
100+ var supportedOutputs = FeatureDefinition . Output ? . Keys ?? Enumerable . Empty < string > ( ) ;
101+ var supportedList = supportedOutputs . Any ( )
102+ ? string . Join ( ", " , supportedOutputs )
103+ : "none" ;
104+ throw new ButtplugDeviceException (
105+ $ "Feature { FeatureIndex } ({ FeatureDescriptor } ) on device '{ Device . Name } ' does not support output type '{ command . OutputType } '. " +
106+ $ "Supported outputs: { supportedList } .") ;
100107 }
101108
102109 // Get the output definition to determine step range
@@ -115,7 +122,9 @@ public async Task RunOutputAsync(DeviceOutputCommand command, CancellationToken
115122 {
116123 if ( ! command . Duration . HasValue )
117124 {
118- throw new ButtplugDeviceException ( "PositionWithDuration requires a duration value" ) ;
125+ throw new ButtplugDeviceException (
126+ $ "PositionWithDuration command for feature { FeatureIndex } ({ FeatureDescriptor } ) on device '{ Device . Name } ' requires a duration value. " +
127+ "Use DeviceOutput.PositionWithDuration.Percent(position, durationMs) or DeviceOutput.PositionWithDuration.Steps(steps, durationMs)." ) ;
119128 }
120129 cmd = OutputCmd . CreatePositionWithDuration ( Device . Index , FeatureIndex , actualValue , command . Duration . Value ) ;
121130 }
@@ -138,7 +147,13 @@ public async Task<InputReading> RunInputAsync(DeviceInputCommand command, Cancel
138147 {
139148 if ( ! HasInput ( command . InputType ) )
140149 {
141- throw new ButtplugDeviceException ( $ "Feature { FeatureIndex } on device { Device . Name } does not support input type { command . InputType } ") ;
150+ var supportedInputs = FeatureDefinition . Input ? . Keys ?? Enumerable . Empty < string > ( ) ;
151+ var supportedList = supportedInputs . Any ( )
152+ ? string . Join ( ", " , supportedInputs )
153+ : "none" ;
154+ throw new ButtplugDeviceException (
155+ $ "Feature { FeatureIndex } ({ FeatureDescriptor } ) on device '{ Device . Name } ' does not support input type '{ command . InputType } '. " +
156+ $ "Supported inputs: { supportedList } .") ;
142157 }
143158
144159 var cmd = new InputCmd ( Device . Index , FeatureIndex , command . InputType , command . CommandType ) ;
0 commit comments