diff --git a/src/main/java/net/moonlightflower/wc3libs/bin/GameExe.java b/src/main/java/net/moonlightflower/wc3libs/bin/GameExe.java index 6a6ab65..1acf1c8 100644 --- a/src/main/java/net/moonlightflower/wc3libs/bin/GameExe.java +++ b/src/main/java/net/moonlightflower/wc3libs/bin/GameExe.java @@ -5,6 +5,10 @@ import net.moonlightflower.wc3libs.port.GameVersion; import javax.annotation.Nonnull; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.*; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -15,13 +19,18 @@ import java.util.regex.Pattern; public class GameExe { + private static final Logger log = LoggerFactory.getLogger(GameExe.class.getName()); + @Nonnull public static String getVersionString(@Nonnull File file) throws IOException { try { String s = file.getAbsolutePath(); + log.info("Querying {} with dorkbox PE", s); return PE.getVersion(s); } catch (Exception e) { + log.info("Falling back to WMIC due to {}", e); + File tmpBat = File.createTempFile("getVersionString", "tmp_proxy.bat"); tmpBat.deleteOnExit(); @@ -65,7 +74,12 @@ public static String getVersionString(@Nonnull File file) throws IOException { if (versionString.isEmpty()) versionString = null; if (versionString == null) { - throw new IOException(e.getMessage() + "; " + sb.toString()); + throw new IOException( + "Version string " + + sb.toString() + + " from file produced by WMIC wasn't readable. " + + "This is the second failed attempt after dorkbox PE failed with exception.", + e); } return versionString;