Swirrl / csv2rdf

Clojure library and command line application for converting CSV to RDF. An implementation of the W3C CSVW specifications
Eclipse Public License 1.0
27 stars 6 forks source link

Return code / system.exit() #49

Closed ajtucker closed 3 years ago

ajtucker commented 3 years ago

Any chance you could return an error code on exception? I'm always surprised that the JVM doesn't do this automatically, but if an unhandled exception is raised, the return code defaults to 0 (success).

Robsteranium commented 3 years ago

Urgh! It looks like the JVM uses the exit code for itself and not the application it's running.

That was certainly unexpected news!

Wdyt @lkitching? Perhaps we could just wrap csv2rdf.main/-main in something like:

(try
  ,,,
  (catch Exception e
    (log/error e)
    (System/exit 1)))

:thinking: maybe we need to catch all Throwable?

lkitching commented 3 years ago

Yes that would be the simplest fix. It might be worth extracting details like this into a protocol representing the execution environment to keep the entry point small but catching the exception in main seems fine for now.