Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9184327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:01:13+00:00 2026-06-17T19:01:13+00:00

When using xmlrpclib in python an error on the server side is reported by

  • 0

When using xmlrpclib in python an error on the server side is reported by the client side as an xmlrpclib.Fault. A division by zero error in a method on the server side (using SimpleXMLRPCServer) usually gives an output like the following:

xmlrpclib.Fault: <Fault 1: "<type 'exceptions.ZeroDivisionError'>:integer division or modulo by zero">

This is useful as it notes the type of error, but now where it happened. How is it possible to overwrite/modify the xmlrpclib.Fault method (in SimpleXMLRPCServer?) so it reports the error e.g. as follows:

xmlrpclib.Fault: <Fault 1: "<type 'exceptions.ZeroDivisionError'>:integer division or modulo by zero MODULE: myMethod.py  LINE: 657">

i.e. to include the name of the module the error appeared and the line number. Is that possible to do on the server-side, without raising custom exceptions? ANY error should reported in the same way on the client side.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:01:14+00:00Added an answer on June 17, 2026 at 7:01 pm

    If you use SimpleXMLRPCServer, you can override the internal _marshaled_dispatch method to add information to the Fault() instance generated:

    This is the original method:

    def _marshaled_dispatch(self, data, dispatch_method = None, path = None):
        try:
            params, method = xmlrpclib.loads(data)
    
            # generate response
            if dispatch_method is not None:
                response = dispatch_method(method, params)
            else:
                response = self._dispatch(method, params)
            # wrap response in a singleton tuple
            response = (response,)
            response = xmlrpclib.dumps(response, methodresponse=1,
                                       allow_none=self.allow_none, encoding=self.encoding)
        except:
            # report low level exception back to server
            # (each dispatcher should have handled their own
            # exceptions)
            exc_type, exc_value = sys.exc_info()[:2]
            response = xmlrpclib.dumps(
                xmlrpclib.Fault(1, "%s:%s" % (exc_type, exc_value)),
                encoding=self.encoding, allow_none=self.allow_none)
        return response
    

    You can subclass SimpleXMLRPCServer.SimpleXMLRPCServer and override this method:

    import SimpleXMLRPCServer
    import sys
    import xmlrbclib
    
    class VerboseFaultXMLRPCServer(SimpleXMLRPCServer.SimpleXMLRPCServer):
        def _marshaled_dispatch(self, data, dispatch_method = None, path = None):
            try:
                params, method = xmlrpclib.loads(data)
    
                # generate response
                if dispatch_method is not None:
                    response = dispatch_method(method, params)
                else:
                    response = self._dispatch(method, params)
                # wrap response in a singleton tuple
                response = (response,)
                response = xmlrpclib.dumps(response, methodresponse=1,
                                           allow_none=self.allow_none, encoding=self.encoding)
            except:
                # report low level exception back to server
                # (each dispatcher should have handled their own
                # exceptions)
                exc_type, exc_value, tb = sys.exc_info()
                while tb.tb_next is not None:
                    tb = tb.tb_next  # find last frame of the traceback
                lineno = tb.tb_lineno
                code = tb.tb_frame.f_code
                filename = code.co_filename
                name = code.co_name
                response = xmlrpclib.dumps(
                    xmlrpclib.Fault(1, "%s:%s FILENAME: %s LINE: %s NAME: %s" % (
                        exc_type, exc_value, filename, lineno, name)),
                    encoding=self.encoding, allow_none=self.allow_none)
            return response
    

    Then use VerboseFaultXMLRPCServer instead of SimpleXMLRPCServer.SimpleXMLRPCServer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using this code: Java Server side: ... out = new PrintWriter(this.client.getOutputStream(), true); ... public
I built an xml-rpc server in Python using SimpleXMLRPCServer, according to the example in
I am using Python's xmlrpclib to make requests to an xml-rpc service. Is there
How using Python I can dynamically generate my call to my xmlrpc server using
I'm using XMLRPC calls from java to python. So my server in python has
How can I send custom HTTP Headers using python xmlrpclib library ! ? I
I'm trying to ping Pingomatic using python. I've written this: import xmlrpclib print START
Using server-side C#, how can I convert a querystring to a JSON string of
I am using a Python script which uses xmlrpclib : import xmlrpclib srv =
On the server side of a xmlrpc server in python I have the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.