mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-08 22:06:16 +01:00
Add PackageError.__str__() so we can also use it in the inherited classes
This commit is contained in:
parent
175a44bc97
commit
c7370522cc
@ -120,28 +120,30 @@ class WorkingCopyOutdated(OscBaseError):
|
||||
class PackageError(OscBaseError):
|
||||
"""Base class for all Package related exceptions"""
|
||||
|
||||
def __init__(self, prj, pac):
|
||||
def __init__(self, prj, pac, msg=None):
|
||||
super().__init__()
|
||||
self.prj = prj
|
||||
self.pac = pac
|
||||
self.msg = msg
|
||||
|
||||
def __str__(self):
|
||||
result = f"{self.__class__.__name__}: {self.prj}/{self.pac}"
|
||||
if self.msg:
|
||||
result += f": {self.msg}"
|
||||
return result
|
||||
|
||||
|
||||
class WorkingCopyInconsistent(PackageError):
|
||||
"""Exception raised when the working copy is in an inconsistent state"""
|
||||
|
||||
def __init__(self, prj, pac, dirty_files, msg):
|
||||
super().__init__(prj, pac)
|
||||
super().__init__(prj, pac, msg)
|
||||
self.dirty_files = dirty_files
|
||||
self.msg = msg
|
||||
|
||||
|
||||
class LinkExpandError(PackageError):
|
||||
"""Exception raised when source link expansion fails"""
|
||||
|
||||
def __init__(self, prj, pac, msg):
|
||||
super().__init__(prj, pac)
|
||||
self.msg = msg
|
||||
|
||||
|
||||
class OscIOError(OscBaseError):
|
||||
def __init__(self, e, msg):
|
||||
@ -187,20 +189,12 @@ class PackageExists(PackageError):
|
||||
Exception raised when a local object already exists
|
||||
"""
|
||||
|
||||
def __init__(self, prj, pac, msg):
|
||||
super().__init__(prj, pac)
|
||||
self.msg = msg
|
||||
|
||||
|
||||
class PackageMissing(PackageError):
|
||||
"""
|
||||
Exception raised when a local object doesn't exist
|
||||
"""
|
||||
|
||||
def __init__(self, prj, pac, msg):
|
||||
super().__init__(prj, pac)
|
||||
self.msg = msg
|
||||
|
||||
|
||||
class PackageFileConflict(PackageError):
|
||||
"""
|
||||
@ -209,13 +203,12 @@ class PackageFileConflict(PackageError):
|
||||
"""
|
||||
|
||||
def __init__(self, prj, pac, file, msg):
|
||||
super().__init__(prj, pac)
|
||||
super().__init__(prj, pac, msg)
|
||||
self.file = file
|
||||
self.msg = msg
|
||||
|
||||
|
||||
class PackageInternalError(PackageError):
|
||||
def __init__(self, prj, pac, msg):
|
||||
super().__init__(prj, pac)
|
||||
self.msg = msg
|
||||
pass
|
||||
|
||||
|
||||
# vim: sw=4 et
|
||||
|
Loading…
Reference in New Issue
Block a user