Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
import java.util.stream.Stream;

import org.bndtools.core.ui.icons.Icons;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ColumnLabelProvider;
Expand Down Expand Up @@ -49,6 +52,7 @@
import aQute.bnd.wstemplates.FragmentTemplateEngine;
import aQute.bnd.wstemplates.FragmentTemplateEngine.TemplateInfo;
import aQute.bnd.wstemplates.FragmentTemplateEngine.TemplateUpdater;
import bndtools.Plugin;
import bndtools.central.Central;
import bndtools.util.ui.UI;

Expand Down Expand Up @@ -86,6 +90,19 @@ public NewWorkspaceWizard() throws Exception {
ui.write(() -> model.templates = templates.getAvailableTemplates());
} catch (Exception e) {
log.error("failed to read default index {}", e, e);

Display.getDefault()
.asyncExec(() -> {

IStatus status = new Status(IStatus.ERROR, Plugin.PLUGIN_ID, "failed to read default index",
e);
ErrorDialog.openError(getShell(), "Error", "An error occurred", status);
});

Plugin.getDefault()
.getLog()
.log(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0,
"failed to read default index " + DEFAULT_INDEX, e));
}
});
job.schedule();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
import org.osgi.service.component.ComponentConstants;
import org.osgi.util.promise.Promise;

import aQute.bnd.osgi.Processor;
import aQute.bnd.exceptions.Exceptions;
import aQute.bnd.osgi.Processor;
import aQute.lib.io.IO;
import aQute.libg.tuple.Pair;
import bndtools.Plugin;
Expand Down Expand Up @@ -294,11 +294,20 @@ public void run(IProgressMonitor progress) throws InvocationTargetException {
try {
Throwable failure = namedPromise.getSecond()
.getFailure();
if (failure != null)
if (failure != null) {

shell.getDisplay()
.asyncExec(() -> {
IStatus status = new Status(IStatus.ERROR, Plugin.PLUGIN_ID,
"Error loading templates", failure);
ErrorDialog.openError(shell, "Error", "An error occurred", status);
});

Plugin.getDefault()
.getLog()
.log(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0,
"Failed to load from template loader: " + name, failure));
}
else {
Collection<Template> loadedTemplates = namedPromise.getSecond()
.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ public byte[] download(URI uri) throws Exception {
TaggedData td = client.connectTagged(uri.toURL());
if (td == null || td.isNotFound())
throw new FileNotFoundException("Not found");

if (td.getInputStream() == null) {
throwNoResponseError(td);
}

data = IO.read(td.getInputStream());
if (td.getTag() != null)
cache.put(uri, new Pair<>(td.getTag(), data));
Expand All @@ -41,6 +46,11 @@ public byte[] download(URI uri) throws Exception {
data = cachedTag.getSecond();
} else {
// changed

if (td.getInputStream() == null) {
throwNoResponseError(td);
}

data = IO.read(td.getInputStream());
if (td.getTag() == null) {
// server now not giving an etag -> remove from cache
Expand All @@ -59,4 +69,9 @@ public byte[] download(URI uri) throws Exception {
}
}

private void throwNoResponseError(TaggedData td) throws IOException {
throw new IOException("Error (HTTP " + td.getResponseCode() + ") - no response: " + td
+ " (Check https://bnd.bndtools.org/instructions/connection-settings.html in case of connection or authentication errors.)");
}

}
Loading