@@ -354,26 +354,30 @@ class MicrobitWebUSBConnectionImpl
354
354
} ) ;
355
355
}
356
356
357
- async disconnect ( ) : Promise < void > {
357
+ async disconnect ( quiet ?: boolean ) : Promise < void > {
358
358
try {
359
359
if ( this . connection ) {
360
360
await this . stopSerialInternal ( ) ;
361
361
await this . connection . disconnectAsync ( ) ;
362
362
}
363
363
} catch ( e ) {
364
- this . log ( "Error during disconnection:\r\n" + e ) ;
365
- this . logging . event ( {
366
- type : "WebUSB-error" ,
367
- message : "error-disconnecting" ,
368
- } ) ;
364
+ if ( ! quiet ) {
365
+ this . log ( "Error during disconnection:\r\n" + e ) ;
366
+ this . logging . event ( {
367
+ type : "WebUSB-error" ,
368
+ message : "error-disconnecting" ,
369
+ } ) ;
370
+ }
369
371
} finally {
370
372
this . connection = undefined ;
371
373
this . setStatus ( ConnectionStatus . DISCONNECTED ) ;
372
- this . logging . log ( "Disconnection complete" ) ;
373
- this . logging . event ( {
374
- type : "WebUSB-info" ,
375
- message : "disconnected" ,
376
- } ) ;
374
+ if ( ! quiet ) {
375
+ this . logging . log ( "Disconnection complete" ) ;
376
+ this . logging . event ( {
377
+ type : "WebUSB-info" ,
378
+ message : "disconnected" ,
379
+ } ) ;
380
+ }
377
381
}
378
382
}
379
383
@@ -402,7 +406,7 @@ class MicrobitWebUSBConnectionImpl
402
406
// Disconnect from the microbit.
403
407
// Any new connection reallocates all the internals.
404
408
// Use the top-level API so any listeners reflect that we're disconnected.
405
- await this . disconnect ( ) ;
409
+ await this . disconnect ( true ) ;
406
410
407
411
const enriched = enrichedError ( e ) ;
408
412
// Sanitise error message, replace all special chars with '-', if last char is '-' remove it
0 commit comments