I am using Spark 1.5.2 and I am submitting a job (jar file) using spark-submit command in a yarn cluster mode. I'd like the command to return a custom return code.

In the run method, if I do:
the command will always return 0.

The only way to have something not equal to 0 is to throw an exception and this will return 1.

Is there a way to have a custom return code from the job application?

Thanks a lot!