[Zope-dev] XML-RPC and Exceptions

Philipp Auersperg zope@philosoft.at
Sun, 05 Aug 2001 02:31:56 +0200


0. you have to throw a xmlrpclib.Fault instance in the called method at 
the zope side
    this is then correctly thrown as exception at the xmlrpclib client:

raise xmlrpclib.Fault(<errorcode>,<errormessage>)

1. you have to modify the standard_error_message as:
   <dtml-return error_value>

then you can catch the fault at the client (assume 'server' is the 
connection) :

try:
   server.test()
except xmlrpclib.Fault,f:
   print 'fault:',f

hope that helps
phil

Tobias Oberstein wrote:

>lets say i call some method of an zope object via xml-rpc
>and
>
>* give wrong parameters or
>* throw an exception within the method
>
>for example. then the result served by zope will be a html
>page describing the error, not an XML-RPC fault response
>like the spec describes it.
>
>how can i change this behaviour ?
>
>greets, tobias
>
>
>_______________________________________________
>Zope-Dev maillist  -  Zope-Dev@zope.org
>http://lists.zope.org/mailman/listinfo/zope-dev
>**  No cross posts or HTML encoding!  **
>(Related lists - 
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope )
>