@@ -128,7 +128,9 @@ function* handleUsbConnectPybricks(hotPlugDevice?: USBDevice): Generator {
128128 return ;
129129 }
130130
131- // TODO: show unexpected error message to user here
131+ yield * put (
132+ alertsShowAlert ( 'alerts' , 'unexpectedError' , { error : reqDeviceErr } ) ,
133+ ) ;
132134 console . error ( 'Failed to request USB device:' , reqDeviceErr ) ;
133135 yield * put ( usbDidFailToConnectPybricks ( ) ) ;
134136 yield * cleanup ( ) ;
@@ -186,7 +188,7 @@ function* handleUsbConnectPybricks(hotPlugDevice?: USBDevice): Generator {
186188
187189 const [ , selectErr ] = yield * call ( ( ) => maybe ( usbDevice . selectConfiguration ( 1 ) ) ) ;
188190 if ( selectErr ) {
189- // TODO: show error message to user here
191+ yield * put ( alertsShowAlert ( 'alerts' , 'unexpectedError' , { error : selectErr } ) ) ;
190192 console . error ( 'Failed to select USB device configuration:' , selectErr ) ;
191193 yield * put ( usbDidFailToConnectPybricks ( ) ) ;
192194 yield * cleanup ( ) ;
@@ -257,7 +259,11 @@ function* handleUsbConnectPybricks(hotPlugDevice?: USBDevice): Generator {
257259 ) ,
258260 ) ;
259261 if ( fwVerError || fwVerResult ?. status !== 'ok' ) {
260- // TODO: show error message to user here
262+ yield * put (
263+ alertsShowAlert ( 'alerts' , 'unexpectedError' , {
264+ error : fwVerError || ensureError ( fwVerResult ?. status ) ,
265+ } ) ,
266+ ) ;
261267 console . error ( 'Failed to get firmware version:' , fwVerError ) ;
262268 yield * put ( usbDidFailToConnectPybricks ( ) ) ;
263269 yield * cleanup ( ) ;
@@ -313,7 +319,11 @@ function* handleUsbConnectPybricks(hotPlugDevice?: USBDevice): Generator {
313319 ) ,
314320 ) ;
315321 if ( nameError || nameResult ?. status !== 'ok' ) {
316- // TODO: show error message to user here
322+ yield * put (
323+ alertsShowAlert ( 'alerts' , 'unexpectedError' , {
324+ error : nameError || ensureError ( nameResult ?. status ) ,
325+ } ) ,
326+ ) ;
317327 console . error ( 'Failed to get device name:' , nameError ) ;
318328 yield * put ( usbDidFailToConnectPybricks ( ) ) ;
319329 yield * cleanup ( ) ;
@@ -340,7 +350,11 @@ function* handleUsbConnectPybricks(hotPlugDevice?: USBDevice): Generator {
340350 ) ,
341351 ) ;
342352 if ( swVerError || swVerResult ?. status !== 'ok' ) {
343- // TODO: show error message to user here
353+ yield * put (
354+ alertsShowAlert ( 'alerts' , 'unexpectedError' , {
355+ error : swVerError || ensureError ( swVerResult ?. status ) ,
356+ } ) ,
357+ ) ;
344358 console . error ( 'Failed to get software version:' , swVerError ) ;
345359 yield * put ( usbDidFailToConnectPybricks ( ) ) ;
346360 yield * cleanup ( ) ;
@@ -382,7 +396,11 @@ function* handleUsbConnectPybricks(hotPlugDevice?: USBDevice): Generator {
382396 ) ,
383397 ) ;
384398 if ( hubCapErr || hubCapResult ?. status !== 'ok' ) {
385- // TODO: show error message to user here
399+ yield * put (
400+ alertsShowAlert ( 'alerts' , 'unexpectedError' , {
401+ error : hubCapErr || ensureError ( hubCapResult ?. status ) ,
402+ } ) ,
403+ ) ;
386404 console . error ( 'Failed to get hub capabilities:' , hubCapErr ) ;
387405 yield * put ( usbDidFailToConnectPybricks ( ) ) ;
388406 yield * cleanup ( ) ;
0 commit comments