Commit 29065d2d by Dudás Ádám

storage: revise exception implementations

parent 85f21572
...@@ -60,21 +60,27 @@ class Disk(TimeStampedModel): ...@@ -60,21 +60,27 @@ class Disk(TimeStampedModel):
verbose_name_plural = _('disks') verbose_name_plural = _('disks')
class WrongDiskTypeError(Exception): class WrongDiskTypeError(Exception):
def __init__(self, type):
self.type = type
def __str__(self): def __init__(self, type, message=None):
return ("Operation can't be invoked on a disk of type '%s'." % if message is None:
self.type) message = ("Operation can't be invoked on a disk of type '%s'."
% type)
Exception.__init__(self, message)
self.type = type
class DiskInUseError(Exception): class DiskInUseError(Exception):
def __init__(self, disk):
self.disk = disk
def __str__(self): def __init__(self, disk, message=None):
return ("The requested operation can't be performed on disk " if message is None:
"'%s (%s)' because it is in use." % message = ("The requested operation can't be performed on "
(self.disk.name, self.disk.filename)) "disk '%s (%s)' because it is in use." %
(self.disk.name, self.disk.filename))
Exception.__init__(self, message)
self.disk = disk
@property @property
def path(self): def path(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment