File tree Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -161,17 +161,16 @@ function* handleUsbConnectPybricks(hotPlugDevice?: USBDevice): Generator {
161161 return ;
162162 }
163163
164- // REVISIT: For now, we are making the assumption that there is only one
165- // configuration and it is already selected and that it contains a Pybricks
166- // interface.
167- assert (
168- usbDevice . configuration !== undefined ,
169- 'USB device configuration is undefined' ,
170- ) ;
171- assert (
172- usbDevice . configuration . interfaces . length > 0 ,
173- 'USB device has no interfaces' ,
174- ) ;
164+ const [ , selectErr ] = yield * call ( ( ) => maybe ( usbDevice . selectConfiguration ( 1 ) ) ) ;
165+ if ( selectErr ) {
166+ // TODO: show error message to user here
167+ console . error ( 'Failed to select USB device configuration:' , selectErr ) ;
168+ yield * put ( usbDidFailToConnectPybricks ( ) ) ;
169+ yield * cleanup ( ) ;
170+ return ;
171+ }
172+
173+ assert ( usbDevice . configuration !== null , 'USB device configuration is null' ) ;
175174
176175 const iface = usbDevice . configuration . interfaces . find (
177176 ( iface ) =>
You can’t perform that action at this time.
0 commit comments