Change CertificateError to subclass GanetiApiError
authorChris Schrier <schrierc@google.com>
Fri, 20 Apr 2012 16:22:25 +0000 (12:22 -0400)
committerMichael Hanselmann <hansmi@google.com>
Fri, 20 Apr 2012 18:01:45 +0000 (20:01 +0200)
Signed-off-by: Chris Schrier <schrierc@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

lib/rapi/client.py

index d68bb62..15e61f4 100644 (file)
@@ -133,13 +133,6 @@ class Error(Exception):
   pass
 
 
-class CertificateError(Error):
-  """Raised when a problem is found with the SSL certificate.
-
-  """
-  pass
-
-
 class GanetiApiError(Error):
   """Generic error raised from Ganeti API.
 
@@ -149,6 +142,13 @@ class GanetiApiError(Error):
     self.code = code
 
 
+class CertificateError(GanetiApiError):
+  """Raised when a problem is found with the SSL certificate.
+
+  """
+  pass
+
+
 def _AppendIf(container, condition, value):
   """Appends to a list if a condition evaluates to truth.
 
@@ -470,7 +470,8 @@ class GanetiRapiClient(object): # pylint: disable=R0904
         curl.perform()
       except pycurl.error, err:
         if err.args[0] in _CURL_SSL_CERT_ERRORS:
-          raise CertificateError("SSL certificate error %s" % err)
+          raise CertificateError("SSL certificate error %s" % err,
+                                 code=err.args[0])
 
         raise GanetiApiError(str(err), code=err.args[0])
     finally: