I have a Java program that processes one file at a time. This Java program is called from a wrapper script which logs the return code from the Java program. There are 2 types of errors. Expected errors and unexpected errors. In both cases I just need to log them. My wrapper knows about 3 different states. 0-OK, 1-PROCESSING_FAILED, 2- ERROR.
Is this a valid approach?
Here is my approach:
enum ReturnCodes {OK,PROCESSING_FAILED,ERROR};
public static void main(String[] args)
{
...
proc.processMyFile();
...
System.exit(ReturnCodes.OK.ordinal());
}
catch (Throwable t)
{
...
System.exit(ReturnCodes.ERROR.ordinal());
}
private void processMyFile()
{
try
{
...
}catch( ExpectedException e)
{
...
System.exit(ReturnCodes.PROCESSING_FAILED.ordinal());
}
}