@@ -287,15 +287,19 @@ function handlers(app, opts, done){
287
287
workspace . updateContent ( cm . getValue ( ) ) ;
288
288
}
289
289
290
- function syntaxCheck ( ) {
290
+ function compile ( ) {
291
291
const { content } = workspace . getState ( ) ;
292
292
// TODO: it is a pain that compile requires `this`
293
293
const result = app . compile ( {
294
294
type : 'bs2' ,
295
295
source : content
296
296
} ) ;
297
- if ( result . error ) {
298
- const err = result . error ;
297
+
298
+ return result . error ;
299
+ }
300
+
301
+ function handleError ( err ) {
302
+ if ( err ) {
299
303
// leaving this in for better debugging of errors
300
304
console . log ( err ) ;
301
305
@@ -310,6 +314,11 @@ function handlers(app, opts, done){
310
314
}
311
315
}
312
316
317
+ function syntaxCheck ( ) {
318
+ const err = compile ( ) ;
319
+ handleError ( err ) ;
320
+ }
321
+
313
322
function transmitInput ( value ) {
314
323
const { device } = store . getState ( ) ;
315
324
const { selected } = device ;
@@ -446,16 +455,7 @@ function handlers(app, opts, done){
446
455
447
456
toast . show ( `'${ filename } ' downloaded successfully` , successToastOpts ) ;
448
457
} )
449
- . catch ( function ( err ) {
450
- // TODO: this is used twice, should be a util or something
451
- // leaving this in for better debugging of errors
452
- console . log ( err ) ;
453
- toast . show ( err . message , errorToastOpts ) ;
454
-
455
- if ( err && err . errorLength ) {
456
- highlighter ( err . errorPosition , err . errorLength ) ;
457
- }
458
- } )
458
+ . catch ( handleError )
459
459
. finally ( function ( ) {
460
460
board . removeListener ( 'progress' , onProgress ) ;
461
461
resetDownloadProgress ( ) ;
@@ -489,6 +489,16 @@ function handlers(app, opts, done){
489
489
const { autoDownload } = device ;
490
490
const { content } = workspace . getState ( ) ;
491
491
492
+ if ( autoDownload ) {
493
+ const err = compile ( ) ;
494
+
495
+ if ( err ) {
496
+ handleError ( err ) ;
497
+ hideOverlay ( ) ;
498
+ return ;
499
+ }
500
+ }
501
+
492
502
const scanOpts = {
493
503
reject : [
494
504
/ B l u e t o o t h - I n c o m i n g - P o r t / ,
0 commit comments