SDK Updater: Better handling of fetch errors.

The remote page now shows fetch errors in the tree.
Using refresh tries to reload error sources.
This commit is contained in:
Raphael
2009-06-29 22:25:08 -07:00
parent fc614476e4
commit ee763d1307
5 changed files with 46 additions and 5 deletions

View File

@@ -51,6 +51,7 @@ public class RepoSource implements IDescription {
private Package[] mPackages;
private String mDescription;
private String mFetchError;
/**
* Constructs a new source for the given repository URL.
@@ -96,6 +97,14 @@ public class RepoSource implements IDescription {
return mDescription == null ? "" : mDescription; //$NON-NLS-1$
}
/**
* Returns the last fetch error description.
* If there was no error, returns null.
*/
public String getFetchError() {
return mFetchError;
}
/**
* Tries to fetch the repository index for the given URL.
*/
@@ -104,6 +113,8 @@ public class RepoSource implements IDescription {
monitor.setProgressMax(4);
setDefaultDescription();
mFetchError = null; // reset fetch error
String url = mUrl;
if (forceHttp) {
@@ -117,6 +128,8 @@ public class RepoSource implements IDescription {
if (xml == null) {
mDescription += String.format("\nFailed to fetch URL %1$s", url);
mFetchError = "Failed to fetch URL";
monitor.setResult("Failed to fetch URL %1$s", url);
return;
}
@@ -125,6 +138,8 @@ public class RepoSource implements IDescription {
if (!validateXml(xml, monitor)) {
mDescription += String.format("\nFailed to validate XML at %1$s", url);
mFetchError = "Failed to validate XML";
monitor.setResult("\nFailed to validate XML at %1$s", url);
return;
}