[wpiutil] Make runtime loader exception message slightly better (#7536)

This commit is contained in:
Thad House
2024-12-14 11:25:27 -08:00
committed by GitHub
parent 4bca79b9af
commit 782459dff4

View File

@@ -16,17 +16,20 @@ public final class RuntimeLoader {
* @return A load error message.
*/
private static String getLoadErrorMessage(String libraryName, UnsatisfiedLinkError ule) {
String jvmLocation = ProcessHandle.current().info().command().orElse("Unknown");
StringBuilder msg = new StringBuilder(512);
msg.append(libraryName)
.append(" could not be loaded from path.\n" + "\tattempted to load for platform ")
.append(CombinedRuntimeLoader.getPlatformPath())
.append("\nLast Load Error: \n")
.append(ule.getMessage())
.append('\n');
.append('\n')
.append(String.format("JVM Location: %s\n", jvmLocation));
if (System.getProperty("os.name").startsWith("Windows")) {
msg.append(
"A common cause of this error is missing the C++ runtime.\n"
+ "Download the latest at https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads\n");
"A common cause of this error is using a JVM with an incorrect MSVC runtime.\n"
+ "Ensure you are using the WPILib JVM (The current running JVM is listed above)\n"
+ "See https://wpilib.org/jvmruntime for more information\n");
}
return msg.toString();
}