Jeremy Katz wrote:
On Mon, 2007-08-20 at 15:41 +0200, Tim Lauridsen wrote:
After adding prepareTransaction & helpers to YumBase a YumBaseError
exception is raised if any thing goes wrong.
but i would be nice to see, if it was Download or GPGCheck or
TestTransaction there went wrong.
So i have created a patch with some extra Yum Exception and make the
different step cast a custom exception.
Just want to know if the naming look sane, before committing.
Naming seems fine -- it's worth making the new exceptions distinct
classes rather than equal, though, so that you can actually distinguish
between them when they're raised
Yes, offcause the make a lot of sense :-) .
New patch added.
Tim
diff --git a/yum/Errors.py b/yum/Errors.py
index 22902bf..d2472aa 100644
--- a/yum/Errors.py
+++ b/yum/Errors.py
@@ -26,6 +26,26 @@ class YumBaseError(exceptions.Exception):
def __str__(self):
return "%s" %(self.value,)
+class YumGPGCheckError(YumBaseError):
+ def __init__(self, value=None):
+ YumBaseError.__init__(self)
+ self.value = value
+
+class YumDownloadError(YumBaseError):
+ def __init__(self, value=None):
+ YumBaseError.__init__(self)
+ self.value = value
+
+class YumTestTransactionError(YumBaseError):
+ def __init__(self, value=None):
+ YumBaseError.__init__(self)
+ self.value = value
+
+class YumRPMCheckError(YumBaseError):
+ def __init__(self, value=None):
+ YumBaseError.__init__(self)
+ self.value = value
+
class LockError(YumBaseError):
def __init__(self, errno, msg):
YumBaseError.__init__(self)
diff --git a/yum/__init__.py b/yum/__init__.py
index ec0ee1b..377fd0f 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2219,7 +2219,7 @@ class YumBase(depsolve.Depsolve):
for error in errors:
errstr.append("%s: %s" %(key, error))
- raise yum.Errors.YumBaseError, errstr
+ raise yum.Errors.YumDownloadError, errstr
return dlpkgs
def _checkSignatures(self,pkgs):
@@ -2233,7 +2233,7 @@ class YumBase(depsolve.Depsolve):
elif result == 1:
self.getKeyForPackage(po, self._askForGPGKeyImport)
else:
- raise yum.Errors.YumBaseError, errmsg
+ raise yum.Errors.YumGPGCheckError, errmsg
return 0
@@ -2255,7 +2255,7 @@ class YumBase(depsolve.Depsolve):
retmsgs = ['ERROR with rpm_check_debug vs depsolve:']
retmsgs.extend(msgs)
retmsgs.append('Please report this error in bugzilla')
- raise yum.Errors.YumBaseError,retmsgs
+ raise yum.Errors.YumRPMCheckError,retmsgs
tsConf = {}
for feature in ['diskspacecheck']: # more to come, I'm sure
@@ -2280,7 +2280,7 @@ class YumBase(depsolve.Depsolve):
errstring = 'Test Transaction Errors: '
for descr in tserrors:
errstring += ' %s\n' % descr
- raise yum.Errors.YumBaseError, errstring
+ raise yum.Errors.YumTestTransactionError, errstring
del self.ts
# put back our depcheck callback
_______________________________________________
Yum-devel mailing list
Yum-devel@linux.duke.edu
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel