Package Gnumed :: Package pycommon :: Module gmExceptions
[frames] | no frames]

Source Code for Module Gnumed.pycommon.gmExceptions

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