Oliver

My sample was just intended to show what I think happens on the server
while transforming the Exception to a String representation.
I showed how it can happen, now I know one place where it happens:

class: org.apache.xmlrpc.Invoker
xmlrpc 1.2b1: line 191
xmlrpc 2.0: line 153

it happens in method 'execute'.
the code (reduced to the main thing):
---8<---
    try
    {
        returnValue = method.invoke(invokeTarget, argValues);
    }
    catch(InvocationTargetException it_e)
    {
        // check whether the thrown exception is XmlRpcException
        Throwable t = it_e.getTargetException();
        if (t instanceof XmlRpcException)
        {
            throw (XmlRpcException) t;
        }
        // It is some other exception
        throw new Exception(t.toString()); // THE POINT
    }
---8<---

As I already explained:
the original exception is extracted from the InvocationTargetException
and the results of toString() are encapsulated into a new 'Exception'!

if you replace
  throw new Exception(t.toString());
by
  throw new Exception(t.getMessage());

you get a shorter response:

java.lang.Exception: <your message here>

So this means, that also the xml writer code simply invokes toString()
on the (Exception-)Object.

apropos version 2.0:
version 2.0 of xmlrpc behaves completely different!

The client code does not throw your exception, it delivers it!
You may then cast the results to type XmlRpcException and call
getMessage on it ... but (no surprise, see code of Invoker):
what will be returned is again:
java.lang.Exception: java.lang.IllegalArgumentException: <your msg>

:-(

Maybe this is not a bug, but a feature.
After all it is up to you to remove the preceeding parts of the message.

Andreas

Reply via email to