mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-02 13:24:12 +01:00
Improve error handling for files on the commandline
Previously, any files that were specified on the commandline but could not be opened were silently ignored. Only if --verify and --upload was specified and _all_ files failed to open, a generic error message was shown. Additionally, if multiple files were specified with --verify or --upload, only the first would be acted on (the others would be openened and shown in the GUI, but not actually verified or uploaded). Now, whenever a file fails to open, an error message is shown (fatal with --verify or --upload, non-fatal otherwise). Furthermore, with --verify or --upload an error is shown when there is not exactly one file on the commandline. Finally, instead of keeping an "opened" variable, the code now just checks the size of "editors" to see if a blank sketch should be opened.
This commit is contained in:
parent
400ae7fdfd
commit
0a3b82af8f
@ -318,7 +318,6 @@ public class Base {
|
|||||||
// Setup board-dependent variables.
|
// Setup board-dependent variables.
|
||||||
onBoardOrPortChange();
|
onBoardOrPortChange();
|
||||||
|
|
||||||
boolean opened = false;
|
|
||||||
boolean doUpload = false;
|
boolean doUpload = false;
|
||||||
boolean doVerify = false;
|
boolean doVerify = false;
|
||||||
boolean doVerbose = false;
|
boolean doVerbose = false;
|
||||||
@ -365,6 +364,9 @@ public class Base {
|
|||||||
filenames.add(args[i]);
|
filenames.add(args[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((doUpload || doVerify) && filenames.size() != 1)
|
||||||
|
showError(null, _("Must specify exactly one sketch file"), null);
|
||||||
|
|
||||||
for (String path: filenames) {
|
for (String path: filenames) {
|
||||||
// Fix a problem with systems that use a non-ASCII languages. Paths are
|
// Fix a problem with systems that use a non-ASCII languages. Paths are
|
||||||
// being passed in with 8.3 syntax, which makes the sketch loader code
|
// being passed in with 8.3 syntax, which makes the sketch loader code
|
||||||
@ -378,20 +380,22 @@ public class Base {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!new File(path).isAbsolute()) {
|
if (!new File(path).isAbsolute()) {
|
||||||
path = new File(currentDirectory, path).getAbsolutePath();
|
path = new File(currentDirectory, path).getAbsolutePath();
|
||||||
}
|
}
|
||||||
if (handleOpen(path) != null) {
|
|
||||||
opened = true;
|
if (handleOpen(path) == null) {
|
||||||
|
String mess = I18n.format(_("Failed to open sketch: \"{0}\""), path);
|
||||||
|
// Open failure is fatal in upload/verify mode
|
||||||
|
if (doUpload || doVerify)
|
||||||
|
showError(null, mess, null);
|
||||||
|
else
|
||||||
|
showWarning(null, mess, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doUpload || doVerify) {
|
if (doUpload || doVerify) {
|
||||||
if (!opened) {
|
|
||||||
System.out.println(_("Can't open source sketch!"));
|
|
||||||
System.exit(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set verbosity for command line build
|
// Set verbosity for command line build
|
||||||
Preferences.set("build.verbose", "" + doVerbose);
|
Preferences.set("build.verbose", "" + doVerbose);
|
||||||
Preferences.set("upload.verbose", "" + doVerbose);
|
Preferences.set("upload.verbose", "" + doVerbose);
|
||||||
@ -425,11 +429,10 @@ public class Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if there were previously opened sketches to be restored
|
// Check if there were previously opened sketches to be restored
|
||||||
if (restoreSketches())
|
restoreSketches();
|
||||||
opened = true;
|
|
||||||
|
|
||||||
// Create a new empty window (will be replaced with any files to be opened)
|
// Create a new empty window (will be replaced with any files to be opened)
|
||||||
if (!opened) {
|
if (editors.isEmpty()) {
|
||||||
handleNew();
|
handleNew();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user