mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-26 20:54:22 +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()));
|
||||
}
|
||||
|
||||
try {
|
||||
success = uploader.uploadUsingPreferences(buildPath, suggestedClassName, usingProgrammer);
|
||||
|
||||
} finally {
|
||||
if (uploader.requiresAuthorization() && !success) {
|
||||
Preferences.remove(uploader.getAuthorizationKey());
|
||||
}
|
||||
}
|
||||
|
||||
} while (uploader.requiresAuthorization() && !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");
|
||||
get.setRequestHeader("Authorization", "Basic " + auth);
|
||||
try {
|
||||
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;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user