Skip to content

Commit 403a278

Browse files
committed
No error should be given when the arduino ide environments file is not present.
1 parent f55d4c3 commit 403a278

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

it.baeyens.arduino.core/src/it/baeyens/arduino/tools/ArduinoHelpers.java

+21-23
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.io.DataInputStream;
99
import java.io.File;
1010
import java.io.FileInputStream;
11+
import java.io.FileNotFoundException;
1112
import java.io.IOException;
1213
import java.io.InputStream;
1314
import java.io.InputStreamReader;
@@ -624,10 +625,8 @@ private static void setTheEnvironmentVariablesSetTheDefaults(IContributedEnviron
624625
* @param confDesc
625626
* @param envVarFile
626627
* The file to parse
627-
* @throws IOException
628628
*/
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) {
631630
try (DataInputStream dataInputStream = new DataInputStream(new FileInputStream(envVarFile.toOSString()));
632631
BufferedReader br = new BufferedReader(new InputStreamReader(dataInputStream));) {
633632
String strLine;
@@ -650,7 +649,10 @@ private static void setTheEnvironmentVariablesAddAFile(IContributedEnvironment c
650649
}
651650
}
652651
}
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));
654656
}
655657
}
656658

@@ -663,10 +665,9 @@ private static void setTheEnvironmentVariablesAddAFile(IContributedEnvironment c
663665
* @param confDesc
664666
* @param platformFilename
665667
* The file to parse
666-
* @throws IOException
667668
*/
668669
private static void setTheEnvironmentVariablesAddtheBoardsTxt(IContributedEnvironment contribEnv, ICConfigurationDescription confDesc,
669-
IPath boardFileName, String boardName) throws IOException {
670+
IPath boardFileName, String boardName) {
670671
ArduinoBoards boardsFile = new ArduinoBoards(boardFileName.toOSString());
671672
String boardID = boardsFile.getBoardIDFromName(boardName);
672673

@@ -800,25 +801,22 @@ public static void setTheEnvironmentVariables(IProject project, ICConfigurationD
800801
// overwrite the default settings
801802
setTheEnvironmentVariablesSetTheDefaults(contribEnv, confDesc, platformFilename);
802803

803-
try {
804-
IPath arduinoIDEVarsFile = new Path(Common.getArduinoIDEEnvVarsName().getCanonicalPath());
804+
if (Common.getArduinoIDEEnvVarsName().exists()) {
805+
IPath arduinoIDEVarsFile = new Path(Common.getArduinoIDEEnvVarsName().getPath());
805806
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);
818819

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;
822820
}
823821

824822
}

0 commit comments

Comments
 (0)