8
8
import java .io .DataInputStream ;
9
9
import java .io .File ;
10
10
import java .io .FileInputStream ;
11
+ import java .io .FileNotFoundException ;
11
12
import java .io .IOException ;
12
13
import java .io .InputStream ;
13
14
import java .io .InputStreamReader ;
@@ -624,10 +625,8 @@ private static void setTheEnvironmentVariablesSetTheDefaults(IContributedEnviron
624
625
* @param confDesc
625
626
* @param envVarFile
626
627
* The file to parse
627
- * @throws IOException
628
628
*/
629
- private static void setTheEnvironmentVariablesAddAFile (IContributedEnvironment contribEnv , ICConfigurationDescription confDesc , IPath envVarFile )
630
- throws IOException {
629
+ private static void setTheEnvironmentVariablesAddAFile (IContributedEnvironment contribEnv , ICConfigurationDescription confDesc , IPath envVarFile ) {
631
630
try (DataInputStream dataInputStream = new DataInputStream (new FileInputStream (envVarFile .toOSString ()));
632
631
BufferedReader br = new BufferedReader (new InputStreamReader (dataInputStream ));) {
633
632
String strLine ;
@@ -650,7 +649,10 @@ private static void setTheEnvironmentVariablesAddAFile(IContributedEnvironment c
650
649
}
651
650
}
652
651
}
653
- dataInputStream .close (); // Close the platform.txt
652
+ } catch (FileNotFoundException e ) {
653
+ Common .log (new Status (IStatus .ERROR , ArduinoConst .CORE_PLUGIN_ID , "Error parsing " + envVarFile .toString () + " file does not exist. " , e ));
654
+ } catch (IOException e ) {
655
+ Common .log (new Status (IStatus .ERROR , ArduinoConst .CORE_PLUGIN_ID , "Error parsing " + envVarFile .toString () + " I/O exception. " , e ));
654
656
}
655
657
}
656
658
@@ -663,10 +665,9 @@ private static void setTheEnvironmentVariablesAddAFile(IContributedEnvironment c
663
665
* @param confDesc
664
666
* @param platformFilename
665
667
* The file to parse
666
- * @throws IOException
667
668
*/
668
669
private static void setTheEnvironmentVariablesAddtheBoardsTxt (IContributedEnvironment contribEnv , ICConfigurationDescription confDesc ,
669
- IPath boardFileName , String boardName ) throws IOException {
670
+ IPath boardFileName , String boardName ) {
670
671
ArduinoBoards boardsFile = new ArduinoBoards (boardFileName .toOSString ());
671
672
String boardID = boardsFile .getBoardIDFromName (boardName );
672
673
@@ -800,25 +801,22 @@ public static void setTheEnvironmentVariables(IProject project, ICConfigurationD
800
801
// overwrite the default settings
801
802
setTheEnvironmentVariablesSetTheDefaults (contribEnv , confDesc , platformFilename );
802
803
803
- try {
804
- IPath arduinoIDEVarsFile = new Path (Common .getArduinoIDEEnvVarsName ().getCanonicalPath ());
804
+ if ( Common . getArduinoIDEEnvVarsName (). exists ()) {
805
+ IPath arduinoIDEVarsFile = new Path (Common .getArduinoIDEEnvVarsName ().getPath ());
805
806
setTheEnvironmentVariablesAddAFile (contribEnv , confDesc , arduinoIDEVarsFile );
806
- // process the platform.txt file first. This way the boards.txt will
807
- // overwrite the default settings
808
- setTheEnvironmentVariablesAddAFile ( contribEnv , confDesc , platformFilename );
809
- // now process the boards file
810
- setTheEnvironmentVariablesAddtheBoardsTxt ( contribEnv , confDesc , boardFileName , boardName );
811
- // Do some post processing
812
- setTheEnvironmentVariablesPostProcessing ( contribEnv , confDesc );
813
-
814
- // If this is a debug config we modify the environment variables for compilation
815
- if ( debugCompilerSettings ) {
816
- setTheEnvironmentVariablesModifyDebugCompilerSettings ( confDesc , envManager , contribEnv );
817
- }
807
+ }
808
+ // process the platform.txt file first. This way the boards.txt will
809
+ // overwrite the default settings
810
+ setTheEnvironmentVariablesAddAFile ( contribEnv , confDesc , platformFilename );
811
+ // now process the boards file
812
+ setTheEnvironmentVariablesAddtheBoardsTxt ( contribEnv , confDesc , boardFileName , boardName );
813
+ // Do some post processing
814
+ setTheEnvironmentVariablesPostProcessing ( contribEnv , confDesc );
815
+
816
+ // If this is a debug config we modify the environment variables for compilation
817
+ if ( debugCompilerSettings ) {
818
+ setTheEnvironmentVariablesModifyDebugCompilerSettings ( confDesc , envManager , contribEnv );
818
819
819
- } catch (Exception e ) {// Catch exception if any
820
- Common .log (new Status (IStatus .ERROR , ArduinoConst .CORE_PLUGIN_ID , "Error parsing " + platformFilename + " or " + boardFileName , e ));
821
- return ;
822
820
}
823
821
824
822
}
0 commit comments