1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
|
#############################################################################
#
# gmExceptions - classes for exceptions gnumed modules may throw
# ---------------------------------------------------------------------------
#
# @author: Dr. Horst Herb
# @copyright: author
# @license: GPL (details at http://www.gnu.org)
# @dependencies: nil
# @change log:
# 07.02.2002 hherb first draft, untested
#
# @TODO: Almost everything
############################################################################
class ConnectionError(Exception):
#raised whenever the database backend connection fails
def __init__(self, errmsg):
self.errmsg=errmsg
def __str__(self):
return self.errmsg
class ConfigError(Exception):
#raised whenever a configuration error occurs
def __init__(self, errmsg):
self.errmsg=errmsg
def __str__(self):
return self.errmsg
class NoGuiError(Exception):
def __init__(self, errmsg):
self.errmsg=errmsg
def __str__(self):
return self.errmsg
class PureVirtualFunction(Exception):
#raised whenever the database backend connection fails
def __init__(self, errmsg=None):
if errmsg is not None:
self.errmsg=errmsg
else:
self.errmsg="Attempt to call a pure virtual function!"
def __str__(self):
return self.errmsg
#------------------------------------------------------------
# constructor errors
class ConstructorError(Exception):
"""Raised when a constructor fails."""
def __init__(self, errmsg = None):
if errmsg is None:
self.errmsg = "%s.__init__() failed" % self.__class__.__name__
else:
self.errmsg = errmsg
def __str__(self):
return str(self.errmsg)
# business DB-object exceptions
class NoSuchBusinessObjectError(ConstructorError):
"""Raised when a business db-object can not be found."""
def __init__(self, errmsg = None):
if errmsg is None:
self.errmsg = "no such business DB-object found"
else:
self.errmsg = errmsg
def __str__(self):
return str(self.errmsg)
# access errors
class NoSuchBusinessObjectAttributeError(KeyError):
"""Raised when a clinical item attribute can not be found."""
def __init__(self, errmsg = None):
if errmsg is None:
self.errmsg = "no such business DB-object attribute found"
else:
self.errmsg = errmsg
def __str__(self):
return str(self.errmsg)
class BusinessObjectAttributeNotSettableError(KeyError):
"""Raised when a clinical item attribute is not settable."""
def __init__(self, errmsg = None):
if errmsg is None:
self.errmsg = "business DB-object attribute not settable"
else:
self.errmsg = errmsg
def __str__(self):
return str(self.errmsg)
# clinical item exceptions
class NoSuchClinItemError(NoSuchBusinessObjectError):
"""Raised when a clinical item can not be found."""
def __init__(self, errmsg = None):
if errmsg is None:
self.errmsg = "no such clinical item found"
else:
self.errmsg = errmsg
def __str__(self):
return str(self.errmsg)
class NoSuchClinItemAttributeError(NoSuchBusinessObjectAttributeError):
"""Raised when a clinical item attribute can not be found."""
def __init__(self, errmsg = None):
if errmsg is None:
self.errmsg = "no such clinical item attribute found"
else:
self.errmsg = errmsg
def __str__(self):
return str(self.errmsg)
class ClinItemAttributeNotSettableError(BusinessObjectAttributeNotSettableError):
"""Raised when a clinical item attribute is not settable."""
def __init__(self, errmsg = None):
if errmsg is None:
self.errmsg = "clinical item attribute not settable"
else:
self.errmsg = errmsg
def __str__(self):
return str(self.errmsg)
#------------------------------------------------------------
class InvalidInputError(Exception):
"""Raised by business layers when an attempt is made to input
invalid data"""
def __init__(self, errmsg = None):
if errmsg is None:
self.errmsg = "%s.__init__() failed" % self.__class__.__name__
else:
self.errmsg = errmsg
def __str__(self):
return self.errmsg
#=====================================================================
# $Log: gmExceptions.py,v $
# Revision 1.6 2004/10/11 19:07:36 ncq
# - add exceptions for business db class
#
# Revision 1.5 2004/06/02 12:51:45 ncq
# - add exceptions tailored to cClinItem __set/getitem__()
# errors as per Syan's suggestion
#
# Revision 1.4 2004/05/08 17:31:31 ncq
# - add NoSuchClinItemError
#
# Revision 1.3 2004/03/27 04:37:01 ihaywood
# lnk_person2address now lnk_person_org_address
# sundry bugfixes
#
# Revision 1.2 2004/03/10 00:14:04 ncq
# - fix imports
#
# Revision 1.1 2004/02/25 09:30:13 ncq
# - moved here from python-common
#
|