Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[stellation-res] Return codes considered harmful, and should be eliminated

Several of the comments by Jonathan Gossage in his workspace audit
request that the return codes, values, and exit codes be made
symbolic.

The source of many of these notes was in the definition of command()
in the base class Command used for commands:

    public abstract int command() throws IOException;

where the convention was to return 0 for normal completion, 2 if
errors, or 1 in a few rare cases. While this usage is common in C and
C++, there is no need for it in Java. I had planned for some time to 
clean this up, and Jonathan's note prompted me to do so.

The new definition in Command is

    public abstract void command() throws IOException;

This and all related methods that used to return an int now have void
type.  It is assumed execution terminates normally, in which case Svc
will exit with exit status 0. An error is reported by throwing an
exception, which is detected by Svc at the top level, and the exit
status is set to 2. The code for 'differ' and 'test' may want to set
the program exit status to 1, and this is done by throwing the new
exception InformException.

There still remains the task of cleaning up, or at least reviewing,
the use of exceptions throughout Stellation, but that can be left for
a later time.


dave
-- 
Dave Shields, IBM Research, shields@xxxxxxxxxxxxxx. 


Back to the top