Some tidy-ups to exception handling in Native.get().
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user