Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return code / system.exit() #49

Closed
ajtucker opened this issue Feb 24, 2021 · 2 comments
Closed

Return code / system.exit() #49

ajtucker opened this issue Feb 24, 2021 · 2 comments

Comments

@ajtucker
Copy link

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
Copy link
Contributor

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)))

🤔 maybe we need to catch all Throwable?

@lkitching
Copy link
Contributor

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.

lkitching added a commit that referenced this issue Mar 9, 2021
Issue #49 - Wrap main in a try/catch block and exit with a non-zero
exit code in the event of an exception being thrown. The JVM does
not guarantee to set a non-zero code if the program terminates due
to an unhandled exception.

Add a display-error method for displaying unhandled exceptions based
on the :type key of the associated ex-data map if one exists.

Refactor the CLI argument parser to raise an exception if the
arguments are invalid. Display the usage summary in the handler for
invalid CLI exceptions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants