Improved error handling for case where native library for current architecture is not available.

This commit is contained in:
Adam Murdoch
2012-09-03 13:59:46 +10:00
parent efa6e683ee
commit 066a2be380

View File

@@ -42,6 +42,9 @@ public class Native {
} else { } else {
libFile = new File("build/binaries/" + platform.getLibraryName()); libFile = new File("build/binaries/" + platform.getLibraryName());
} }
if (!libFile.isFile()) {
throw new NativeIntegrationUnavailableException(String.format("Native library is not available for this operating system and architecture."));
}
System.load(libFile.getCanonicalPath()); System.load(libFile.getCanonicalPath());
int nativeVersion = NativeLibraryFunctions.getVersion(); int nativeVersion = NativeLibraryFunctions.getVersion();
if (nativeVersion != NativeLibraryFunctions.VERSION) { if (nativeVersion != NativeLibraryFunctions.VERSION) {
@@ -52,8 +55,8 @@ public class Native {
loaded = true; loaded = true;
} catch (NativeException e) { } catch (NativeException e) {
throw e; throw e;
} catch (Exception e) { } catch (Throwable t) {
throw new NativeException("Failed to initialise native integration.", e); throw new NativeException("Failed to initialise native integration.", t);
} }
} }
} }
@@ -75,8 +78,8 @@ public class Native {
return platform.get(type); return platform.get(type);
} catch (NativeException e) { } catch (NativeException e) {
throw e; throw e;
} catch (Exception e) { } catch (Throwable t) {
throw new NativeException(String.format("Failed to load native integration %s.", type.getSimpleName()), e); throw new NativeException(String.format("Failed to load native integration %s.", type.getSimpleName()), t);
} }
} }