cryptonas/src/cryptobox/core/exceptions.py

128 lines
3.1 KiB
Python
Raw Normal View History

2006-11-30 15:50:28 +01:00
#
# Copyright 2006 sense.lab e.V.
#
# This file is part of the CryptoBox.
#
# The CryptoBox is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# The CryptoBox is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the CryptoBox; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
2006-11-06 17:05:00 +01:00
"""
exceptions of the cryptobox package
"""
class CBError(Exception):
2006-11-06 17:05:00 +01:00
"""base class for exceptions of the cryptobox"""
pass
class CBConfigError(CBError):
2006-11-06 17:05:00 +01:00
"""any kind of error related to the configuration of a cryptobox"""
pass
class CBConfigUnavailableError(CBConfigError):
"""config file/input was not available at all"""
def __init__(self, source=None):
self.source = source
def __str__(self):
if self.source:
return "failed to access the configuration of the cryptobox: %s" % self.source
else:
return "failed to access the configuration of the cryptobox"
class CBConfigUndefinedError(CBConfigError):
"""a specific configuration setting was not defined"""
def __init__(self, section, name=None):
self.section = section
self.name = name
def __str__(self):
# is it a settings or a section?
if self.name:
# setting
return "undefined configuration setting: [%s]->%s - please check your configuration file" % (self.section, self.name)
else:
# section
return "undefined configuration section: [%s] - please check your configuration file" % (self.section, )
class CBConfigInvalidValueError(CBConfigError):
"""a configuration setting was invalid somehow"""
def __init__(self, section, name, value, reason):
self.section = section
self.name = name
self.value = value
self.reason = reason
def __str__(self):
return "invalid configuration setting [%s]->%s (%s): %s" % (self.section, self.name, self.value, self.reason)
class CBEnvironmentError(CBError):
2006-11-06 17:05:00 +01:00
"""some part of the environment of the cryptobox is broken
e.g. the wrong version of a required program
"""
def __init__(self, desc):
self.desc = desc
def __str__(self):
return "misconfiguration detected: %s" % self.desc
class CBContainerError(CBError):
2006-11-06 17:05:00 +01:00
"""any error raised while manipulating a cryptobox container"""
def __init__(self, desc):
self.desc = desc
def __str__(self):
return self.desc
class CBCreateError(CBContainerError):
pass
class CBVolumeIsActive(CBContainerError):
pass
class CBInvalidName(CBContainerError):
pass
class CBNameIsInUse(CBContainerError):
2006-11-06 17:05:00 +01:00
pass
class CBInvalidType(CBContainerError):
pass
class CBInvalidPassword(CBContainerError):
pass
class CBChangePasswordError(CBContainerError):
pass
class CBMountError(CBContainerError):
pass
class CBUmountError(CBContainerError):
pass