uw-pluverse / perses

language-agnostic program reducer.
GNU General Public License v3.0
162 stars 22 forks source link

Informative error message for unsupported languages #18

Closed mrigger closed 2 years ago

mrigger commented 2 years ago

I just tried executing Perses on a file with a SQL extension using the command line below:

java -jar perses_deploy.jar --test-script oracle.py --input-file test.sql

This resulted in the following Exception:

Exception in thread "main" kotlin.KotlinNullPointerException
    at org.perses.reduction.ReductionDriver$Companion.createConfiguration(ReductionDriver.kt:540)
    at org.perses.reduction.ReductionDriver.<init>(ReductionDriver.kt:65)
    at org.perses.Main.run(Main.java:91)
    at org.perses.Main.main(Main.java:47)

While this might be expected, I think it would be useful to explicitly check for supported extensions and throw a more informative Exception, or print an error message, when the extension is not supported.

chengniansun commented 2 years ago

Our internal version has better error message, shown as below

Exception in thread "main" java.lang.IllegalStateException: Failed to detect the language kind for file /tmp/tmp.fCqtnqktZv/a.non_existent_language

The available languages are listed below:
  go: exts=[go]
  rust: exts=[rs]
  scala: exts=[scala, sc]
  java: exts=[java]
  c: exts=[c]
  system_verilog: exts=[v, sv]
  solidity: exts=[sol]
  cpp: exts=[cc, cpp, cxx]
  javascript: exts=[javascript, js]
  php: exts=[php]
  smtlibv2: exts=[smt2]
  python3: exts=[py, py3]
  ruby: exts=[rb]

    at org.perses.grammar.AbstractParserFacadeFactory.reportError$src_org_perses_grammar_facade_factory(AbstractParserFacadeFactory.kt:63)
    at org.perses.grammar.AbstractParserFacadeFactory.computeLanguageKindOrThrow(AbstractParserFacadeFactory.kt:50)
    at org.perses.reduction.RegularProgramReductionDriver$Companion.createReductionInputs(RegularProgramReductionDriver.kt:57)
    at org.perses.reduction.RegularProgramReductionDriver$Companion.create(RegularProgramReductionDriver.kt:101)
    at org.perses.Main.createReductionDriver(Main.java:85)
    at org.perses.AbstractMain.internalRun(AbstractMain.kt:33)
    at org.perses.util.cmd.AbstractMain.run(AbstractMain.kt:53)
    at org.perses.Main.main(Main.java:89)

Next week, we will push a release to the public repo. Thanks for reporting. I also added a regression test to make sure in the future we still report such an error message when a language is not supported.

mrigger commented 2 years ago

Awesome, thanks!