@@ -10,9 +10,7 @@ export function exportFlightLogToCSVs(flightLog) {
1010 let paths = dialog . showOpenDialogSync ( { properties : [ "openDirectory" ] } ) ;
1111
1212 if ( ! paths ) {
13- console . log ( "No directory selected for export." ) ;
14- // TODO: after snackbar is merged print error message to user
15- return ;
13+ throw new Error ( "No directory selected for export." ) ;
1614 }
1715
1816 const userFolderPath = path . join ( paths [ 0 ] ) ;
@@ -23,9 +21,7 @@ export function exportFlightLogToCSVs(flightLog) {
2321 for ( let flightLogSection of flightLogSections ) {
2422 fs . writeFile ( `${ exportFolderPath } /${ flightLogSection } .csv` , objectArrayToCSV ( flightLogSection , flightLog [ flightLogSection ] ) , "utf8" , function ( err ) {
2523 if ( err ) {
26- console . log ( "An error occurred while writing CSV object to file." ) ;
27- // TODO: after snackbar is merged print error message to user
28- return console . log ( err ) ;
24+ throw new Error ( `An error occurred while writing CSV object to file.` ) ;
2925 }
3026 } ) ;
3127 }
@@ -35,9 +31,7 @@ export function exportFlightLogChartsToHTML(flightLogChartsHTML) {
3531 let paths = dialog . showOpenDialogSync ( { properties : [ "openDirectory" ] } ) ;
3632
3733 if ( ! paths ) {
38- console . log ( "No directory selected for export." ) ;
39- return ;
40- // TODO: after snackbar is merged print error message to user
34+ throw new Error ( "No directory selected for export." ) ;
4135 }
4236
4337 const exportFolderPath = path . join ( paths [ 0 ] ) ;
@@ -56,9 +50,7 @@ export function exportFlightLogChartsToHTML(flightLogChartsHTML) {
5650
5751 fs . writeFile ( `${ exportFolderPath } /${ flightLogFilename } _plots_${ formatDateTime ( new Date ( ) ) } .html` , flightLogHtmlDocument , 'utf8' , function ( err ) {
5852 if ( err ) {
59- console . log ( "An error occurred while writing HTML Object to File." ) ;
60- return console . log ( err ) ;
61- // TODO: after snackbar is merged print error message to user
53+ throw new Error ( `An error occurred while writing HTML Object to File.` ) ;
6254 }
6355 } ) ;
6456}
0 commit comments