Skip to content

Commit

Permalink
Using Status.error in TychoRepositoryTransport
Browse files Browse the repository at this point in the history
Status.error could be used in TychoRepositoryTransport instead of the
older and longer API. As errors are not the normal case, the overhead of
the StackWalker should not affect regular builds.
  • Loading branch information
vogella authored and laeubi committed Nov 23, 2023
1 parent c0960be commit a6dfcba
Showing 1 changed file with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ public TychoRepositoryTransport() {
@Override
public IStatus download(URI toDownload, OutputStream target, long startPos, IProgressMonitor monitor) {
if (startPos > 0) {
return new Status(IStatus.ERROR, TychoRepositoryTransport.class.getName(),
"range downloads are not implemented");
return Status.error("range downloads are not implemented");
}
return download(toDownload, target, monitor);
}
Expand All @@ -111,11 +110,9 @@ public IStatus download(URI toDownload, OutputStream target, IProgressMonitor mo
}
return reportStatus(downloadStatus, target);
} catch (AuthenticationFailedException e) {
return new Status(IStatus.ERROR, TychoRepositoryTransport.class.getName(),
"authentication failed for " + toDownload, e);
return Status.error("authentication failed for " + toDownload, e);
} catch (IOException e) {
return reportStatus(new Status(IStatus.ERROR, TychoRepositoryTransport.class.getName(),
"download from " + toDownload + " failed", e), target);
return reportStatus(Status.error("download from " + toDownload + " failed", e), target);
} catch (CoreException e) {
return reportStatus(e.getStatus(), target);
}
Expand Down Expand Up @@ -162,8 +159,7 @@ public InputStream stream(URI toDownload, IProgressMonitor monitor)
if (DEBUG_REQUESTS) {
logger.debug(" --> generic error: " + e);
}
throw new CoreException(new Status(IStatus.ERROR, TychoRepositoryTransport.class.getName(),
"download from " + toDownload + " failed", e));
throw new CoreException(Status.error("download from " + toDownload + " failed", e));
} finally {
if (DEBUG_REQUESTS) {
logger.debug("Total number of requests: " + requests.longValue() + " (" + indexRequests.longValue()
Expand Down Expand Up @@ -199,8 +195,7 @@ public long getLastModified(URI toDownload, IProgressMonitor monitor)
} catch (FileNotFoundException e) {
throw e;
} catch (IOException e) {
throw new CoreException(new Status(IStatus.ERROR, TychoRepositoryTransport.class.getName(),
"download from " + toDownload + " failed", e));
throw new CoreException(Status.error("download from " + toDownload + " failed", e));
}
}

Expand Down

0 comments on commit a6dfcba

Please sign in to comment.