dev@glassfish.java.net

Re: asadmin output behaviour

From: Bill Shannon <bill.shannon_at_oracle.com>
Date: Fri, 11 Jun 2010 12:06:42 -0700

Yamini K B wrote on 06/ 8/10 04:25 AM:
> Hi,
>
> I have a basic question on asadmin output. In v2.1, in case of error,
> the usage text is displayed before the actual error message. For example:
>
> $ ./asadmin restore-domain domain1
> Usage: restore-domain [--domaindir domain_directory] [--filename
> backup_filename] [--description description] [--terse=false]
> [--echo=false] [--verbose=false] [domain_name]
> The domain must be stopped before a restore-domain can be performed.
>
> Whereas in v3.1, it is reversed:
>
> $ ./asadmin restore-domain
> Domain domain1 is not stopped.
> Usage: asadmin [asadmin-utility-options] restore-domain [--filename
> <filename>]
> [--verbose[=<verbose(default:false)>]] [--description <description>]
> [--domaindir <domaindir>] [-?|--help[=<help(default:false)>]]
> [domain_name]
> Command restore-domain failed.
>
> Is this ok?
>
> My second question is about CommandException and
> CommandValidationException. My understanding is that
> CommandValidationException should be thrown when there is an error while
> validating option or option values which basically indicates incorrect
> usage of command/command options. In the above command, doesn't
> CommandException seem more appropriate since its not a usage error?

Yes.

For a usage error, it seemed to make more sense to describe the specific
error and then the general rules. At least, that's the way it's always
been done in Unix, so that's the way I made it work in v3. I had no idea
v2 was doing it the opposite way, and no one ever complained about that
before... :-)