wurstscript / WurstScript

Programming language and toolkit to create Warcraft III Maps
https://wurstlang.org
Apache License 2.0
226 stars 28 forks source link

warn log instead of printing stacktrace on linux platform #1075

Closed Cokemonkey11 closed 1 year ago

Cokemonkey11 commented 1 year ago

It may be better to update w3utils to throw a different exception to match against for linux versus a not-found mac/windows one, but this seems like a sensible improvement anyway since wurstc just uses latest patch when the version cannot be determined.

To be clear, when this stacktrace appears, wurstc has no problem building a map successfully.

$ grill build base_map.w3x
πŸ”₯ Grill warming up..
πŸ”₯ Ready. Version: <1.3.4.1-jenkins-WurstSetup-157>
πŸ”¨ Building project..
java.nio.file.NoSuchFileException: /mnt/c/Users/Cokem/workspace/..././wurst/_build/dependencies
        at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
        at sun.nio.fs.UnixFileSystemProvider.newDirectoryStream(UnixFileSystemProvider.java:427)
        at java.nio.file.Files.newDirectoryStream(Files.java:457)
        at java.nio.file.Files.list(Files.java:3451)
        at de.peeeq.wurstio.map.importer.ImportFile.getTransientImportDirectories(ImportFile.java:216)
        at de.peeeq.wurstio.map.importer.ImportFile.importFilesFromImports(ImportFile.java:188)
        at de.peeeq.wurstio.WurstCompilerJassImpl.runCompiletime(WurstCompilerJassImpl.java:125)
        at de.peeeq.wurstio.CompilationProcess.lambda$doCompilation$3(CompilationProcess.java:88)
        at de.peeeq.wurstio.TimeTaker.lambda$measure$0(TimeTaker.java:15)
        at de.peeeq.wurstio.TimeTaker$Default.measure(TimeTaker.java:33)
        at de.peeeq.wurstio.TimeTaker.measure(TimeTaker.java:14)
        at de.peeeq.wurstio.CompilationProcess.doCompilation(CompilationProcess.java:88)
        at de.peeeq.wurstio.Main.main(Main.java:146)
net.moonlightflower.wc3libs.port.NotFoundException: java.lang.Exception: system not supported: Linux
        at net.moonlightflower.wc3libs.port.StdGameExeFinder.find(StdGameExeFinder.java:41)
        at net.moonlightflower.wc3libs.port.StdGameExeFinder.find(StdGameExeFinder.java:9)
        at net.moonlightflower.wc3libs.port.Finder.get(Finder.java:25)
        at de.peeeq.wurstio.utils.W3InstallationData.discoverExePath(W3InstallationData.java:71)
        at de.peeeq.wurstio.utils.W3InstallationData.<init>(W3InstallationData.java:28)
        at de.peeeq.wurstio.Main.main(Main.java:164)
Caused by: java.lang.Exception: system not supported: Linux
        ... 6 more
net.moonlightflower.wc3libs.port.NotFoundException: java.lang.Exception: system not supported: Linux
        at net.moonlightflower.wc3libs.port.StdGameVersionFinder.find(StdGameVersionFinder.java:43)
        at net.moonlightflower.wc3libs.port.StdGameVersionFinder.find(StdGameVersionFinder.java:12)
        at net.moonlightflower.wc3libs.port.Finder.get(Finder.java:25)
        at de.peeeq.wurstio.utils.W3InstallationData.discoverVersion(W3InstallationData.java:80)
        at de.peeeq.wurstio.utils.W3InstallationData.<init>(W3InstallationData.java:29)
        at de.peeeq.wurstio.Main.main(Main.java:164)
Caused by: java.lang.Exception: system not supported: Linux
        ... 6 more
Build succeeded. Output file: </mnt/c/Users/Cokem/workspace/....w3x>
compilation finished (errors: 0, warnings: 0)
πŸ—ΊοΈ Map has been built!
Frotty commented 1 year ago

I guess it could have problems if it builds for wrong patch due to not being able to detect version. But I think it's not configurable right now anyway. Does the warning show in the grill terminal?

Cokemonkey11 commented 1 year ago

@Frotty thanks for the swift review

I don't know if WLogger writes to terminal but I suspect that it only goes to the log file.

You are right that a user on an old patch might now be missing error information in the terminal, but such a user I hope would figure out to check logs

As I said, a better fix would be if w3utils used a different exception. Then we could continue supporting users on an old w3 version while suppressing the error for Linux users? Another option might be to remove the error/warn entirely and just log to the user that the installation version couldn't be found for (reason) and that wurst is building a map file for (default version)

Let me know how much you care about this? My goal was just to do a quick and simple clean up, because I think the exception is useful but only in log file