Skip to content

DefaultIOService: Notify in case suitable IOPlugins could not be found. #350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
12 changes: 10 additions & 2 deletions src/main/java/org/scijava/io/DefaultIOService.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,16 @@ public final class DefaultIOService
@Override
public Object open(final String source) throws IOException {
final IOPlugin<?> opener = getOpener(source);
if (opener == null) return null; // no appropriate IOPlugin
if (opener == null) {
log.error("No opener IOPlugin found for " + source + ".");
return null;
}

final Object data = opener.open(source);
if (data == null) return null; // IOPlugin returned no data; canceled?
if (data == null) {
log.warn("Opener IOPlugin " + opener + " returned no data. Canceled?");
return null; // IOPlugin returned no data; canceled?
}

eventService.publish(new DataOpenedEvent(source, data));
return data;
Expand All @@ -81,6 +87,8 @@ public void save(final Object data, final String destination)
if (saver != null) {
saver.save(data, destination);
eventService.publish(new DataSavedEvent(destination, data));
} else {
log.error("No Saver IOPlugin found for " + data.toString() + ".");
}
}
}