Changeset 1b57352


Ignore:
Timestamp:
Nov 28, 2008 4:04:25 PM (16 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
Children:
0a20ef8
Parents:
a2da110
Message:

Deal with common connection and SSL errors cleanly

Location:
fedd
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fedd/fedd.py

    ra2da110 r1b57352  
    9191        self.xmlrpc_methods = impl.xmlrpc_services
    9292        self.log = logging.getLogger("fedd")
     93
     94    def handle_error(self, request, address):
     95        """
     96        The default SSLServer prints a stack trace here.  This is a little
     97        friendlier.
     98        """
     99        if request or address:
     100            self.log.warn("[fedd] Error on incoming connection: %s %s" % \
     101                    (request, address))
     102        else:
     103            self.log.warn("[fedd] Error on incoming connection " + \
     104                    "(Likely SSL error)")
    93105
    94106class fedd_soap_handler(BaseHTTPRequestHandler):
  • fedd/remote_service.py

    ra2da110 r1b57352  
    22
    33import copy
     4
     5from socket import error as socket_error
    46
    57import M2Crypto.httpslib
    68from M2Crypto.m2xmlrpclib import SSL_Transport
     9from M2Crypto.SSL import SSLError
    710from ZSI import ParseException, FaultException, SoapWriter
    811
     
    290293            resp = remote_method(self.apply_to_tags(\
    291294                    { self.request_body_name: r}, self.encap_fedids))
     295        except socket_error, e:
     296            raise service_error(service_error.protocol,
     297                    "Cannot connect to %s: %s" % (url, e[1]))
     298        except SSLError, e:
     299            raise service_error(service_error.protocol,
     300                    "SSL error contacting %s: %s" % (url, e.message))
    292301        except Fault, f:
    293302            raise service_error(None, f.faultString, f.faultCode)
     
    345354        try:
    346355            resp = remote_method(msg)
     356        except socket_error, e:
     357            raise service_error(service_error.protocol,
     358                    "Cannot connect to %s: %s" % (url, e[1]))
     359        except SSLError, e:
     360            raise service_error(service_error.protocol,
     361                    "SSL error contacting %s: %s" % (url, e.message))
    347362        except ParseException, e:
    348363            raise service_error(service_error.protocol,
Note: See TracChangeset for help on using the changeset viewer.