1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-11-29 10:24:12 +01:00

Providing error messages when no board is selected.

This commit is contained in:
David A. Mellis 2010-06-12 18:32:32 +00:00
parent 0979ed050b
commit 9fe672fc63
3 changed files with 15 additions and 2 deletions

View File

@ -1520,7 +1520,13 @@ public class Base {
static public Map<String, String> getBoardPreferences() {
return getTarget().getBoards().get(Preferences.get("board"));
Target target = getTarget();
if (target == null) return new LinkedHashMap();
Map map = target.getBoards();
if (map == null) return new LinkedHashMap();
map = (Map) map.get(Preferences.get("board"));
if (map == null) return new LinkedHashMap();
return map;
}

View File

@ -1574,7 +1574,9 @@ public class Sketch {
protected void size(String buildPath, String suggestedClassName)
throws RunnerException {
long size = 0;
long maxsize = Integer.parseInt(Base.getBoardPreferences().get("upload.maximum_size"));
String maxsizeString = Base.getBoardPreferences().get("upload.maximum_size");
if (maxsizeString == null) return;
long maxsize = Integer.parseInt(maxsizeString);
Sizer sizer = new Sizer(buildPath, suggestedClassName);
try {
size = sizer.computeSize();

View File

@ -73,6 +73,11 @@ public class Compiler implements MessageConsumer {
String avrBasePath = Base.getAvrBasePath();
Map<String, String> boardPreferences = Base.getBoardPreferences();
String core = boardPreferences.get("build.core");
if (core == null) {
RunnerException re = new RunnerException("No board selected; please choose a board from the Tools > Board menu.");
re.hideStackTrace();
throw re;
}
String corePath;
if (core.indexOf(':') == -1) {