Some tidy-ups to exception handling in Native.get().

This commit is contained in:
Adam Murdoch
2012-09-01 10:31:15 +10:00
parent b8b96291c6
commit b7f6183c4b
2 changed files with 9 additions and 3 deletions

View File

@@ -70,8 +70,14 @@ public class Native {
public static <T extends NativeIntegration> T get(Class<T> type)
throws NativeIntegrationUnavailableException, NativeException {
init(null);
Platform platform = Platform.current();
return platform.get(type);
try {
Platform platform = Platform.current();
return platform.get(type);
} catch (NativeException e) {
throw e;
} catch (Exception e) {
throw new NativeException(String.format("Failed to load native integration %s.", type.getSimpleName()), e);
}
}
private static void copy(URL source, File dest) {

View File

@@ -34,7 +34,7 @@ public abstract class Platform {
public <T extends NativeIntegration> T get(Class<T> type) {
throw new NativeIntegrationUnavailableException(String.format("Native integration %s is not supported on this operating system (%s %s)",
type.getName(), getOperatingSystem(), getArchitecture()));
type.getSimpleName(), getOperatingSystem(), getArchitecture()));
}
public abstract String getLibraryName() throws NativeIntegrationUnavailableException;