mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-27 21:54:30 +01:00
better error handling on uploading
This commit is contained in:
parent
c174737584
commit
556c6ea5c1
@ -1680,11 +1680,14 @@ public class Sketch {
|
|||||||
Preferences.set(uploader.getAuthorizationKey(), DigestUtils.sha256Hex(dialog.getPassword()));
|
Preferences.set(uploader.getAuthorizationKey(), DigestUtils.sha256Hex(dialog.getPassword()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
success = uploader.uploadUsingPreferences(buildPath, suggestedClassName, usingProgrammer);
|
success = uploader.uploadUsingPreferences(buildPath, suggestedClassName, usingProgrammer);
|
||||||
|
} finally {
|
||||||
if (uploader.requiresAuthorization() && !success) {
|
if (uploader.requiresAuthorization() && !success) {
|
||||||
Preferences.remove(uploader.getAuthorizationKey());
|
Preferences.remove(uploader.getAuthorizationKey());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} while (uploader.requiresAuthorization() && !success);
|
} while (uploader.requiresAuthorization() && !success);
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
|
@ -155,14 +155,17 @@ public class HttpUploader extends Uploader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean boardNotReady(String auth) {
|
protected boolean boardNotReady(String auth) throws RunnerException {
|
||||||
GetMethod get = new GetMethod(baseUrl + "/ready");
|
GetMethod get = new GetMethod(baseUrl + "/ready");
|
||||||
get.setRequestHeader("Authorization", "Basic " + auth);
|
get.setRequestHeader("Authorization", "Basic " + auth);
|
||||||
try {
|
try {
|
||||||
int httpStatus = client.executeMethod(get);
|
int httpStatus = client.executeMethod(get);
|
||||||
|
if (httpStatus % HttpStatus.SC_BAD_REQUEST < 100 || httpStatus % HttpStatus.SC_INTERNAL_SERVER_ERROR < 100) {
|
||||||
|
System.err.println(get.getResponseBodyAsString());
|
||||||
|
throw new RunnerException("Problem knowing if the board was ready");
|
||||||
|
}
|
||||||
return httpStatus != HttpStatus.SC_OK;
|
return httpStatus != HttpStatus.SC_OK;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user