def-gthill / lexurgy

A high-powered sound change applier
GNU General Public License v3.0
44 stars 5 forks source link

Program crashes when running with --compare-versions if the _ev file doesn't exist #26

Closed LingEarth closed 3 years ago

LingEarth commented 3 years ago

If I run lexurgy with the --compare-versions flag before I have run it to create the _ev.wli file, it crashes. Running with -d gives the following error:

Applying changes to words in pereyan.wli
java.io.FileNotFoundException: pereyan_ev.wli (The system cannot find the file specified)
        at java.io.FileInputStream.open0(Native Method)
        at java.io.FileInputStream.open(Unknown Source)
        at java.io.FileInputStream.<init>(Unknown Source)
        at kotlin.io.FilesKt__FileReadWriteKt.forEachLine(FileReadWrite.kt:190)
        at kotlin.io.FilesKt__FileReadWriteKt.readLines(FileReadWrite.kt:219)
        at kotlin.io.FilesKt__FileReadWriteKt.readLines$default(FileReadWrite.kt:217)
        at com.meamoria.lexurgy.WordlistsKt.loadList(Wordlists.kt:7)
        at com.meamoria.lexurgy.sc.SoundChangerJvmKt.changeFiles(SoundChangerJvm.kt:108)
        at com.meamoria.lexurgy.sc.SoundChangerJvmKt.changeFiles(SoundChangerJvm.kt:26)
        at com.meamoria.lexurgy.SC.run(MainJvm.kt:82)
        at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:168)
        at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:176)
        at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:16)
        at com.github.ajalt.clikt.core.CliktCommand.parse(CliktCommand.kt:258)
        at com.github.ajalt.clikt.core.CliktCommand.parse$default(CliktCommand.kt:255)
        at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:273)
        at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:298)
        at com.meamoria.lexurgy.MainJvmKt.main(MainJvm.kt:118)

It would be better to simply display an error about the file not existing, or even just print a warning and then go on to run the sound changes without writing a comparison file.

def-gthill commented 3 years ago

Indeed, the user shouldn't be getting stack traces! I'll take a look...

LingEarth commented 3 years ago

Oh, the stack trace only happened when I ran with -d to see exactly what was going wrong. Without that, it just crashes with no explanation.

def-gthill commented 3 years ago

This is fixed in commit ee277f471caf0b31ce522fd58d7ff91481438549 and will be included in the next release.