[axiom] [axis2] Coding style

Glen Daniels <[email protected]>
Newsgroups gmane.text.xml.axis.devel,gmane.text.xml.commons.devel
Message-ID <[email protected]>
Hey folks:

Quick code commentary....

Here's some code starting at line 85 in SOAP12FaultImpl:

     public void setReason(SOAPFaultReason reason) throws 
SOAPProcessingException {
         if (!(reason instanceof SOAP12FaultReasonImpl)) {
             throw new SOAPProcessingException(
                     "Expecting SOAP 1.2 implementation of SOAP Fault 
Reason. " +
                     "But received some other implementation");
         }
         super.setReason(reason);
     }

Two comments here.

1) Messages should be internationalized and accessed via resource APIs. 
  Really.  At some point we should all stop working on features and take 
a few days to hang out and make a serious push to do this across the 
board.  After that's done we should implement a daily automated scan 
(like Axis1 does on each build) across the source to alert us of 
non-internationalized messages.

2) When generating exceptions like this, it really isn't very useful to 
say "received some other implementation" or "value wasn't what was 
expected".  It's much more helpful to actually put the problem value 
into the exception.... In this case it only takes an extra moment to code

    "but received " + reason.getClass() + "."

    and the more informative results, when you are trying to debug 
something a year and a half later, will be well worth the time.  In 
general our fault messages are not informative enough and we need to do 
better about helping both the developers and the end users.

Clearly this particular example isn't any kind of big deal on its own, 
but we have this kind of thing all over the place and we should a) begin 
working on cleaning it up, and b) be a little more careful when writing 
new code.

We should consider adding these kinds of things to our coding style 
guidelines, IMO.

Thanks,
--Glen
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.