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 v2 or later (details at http://www.gnu.org)
      9  # @dependencies: nil
     10  # @change log:
     11  #       07.02.2002 hherb first draft, untested
     12  ############################################################################
     13
     14 -class AccessDenied(Exception):
     15 -        def __init__(self, msg, source=None, code=None, details=None):
     16                  self.errmsg = msg
     17                  self.source = source
     18                  self.code = code
     19                  self.details = details
     20          #----------------------------------
     21 -        def __str__(self):
     22                  txt = self.errmsg
     23                  if self.source is not None:
     24                          txt += u'\nSource: %s' % self.source
     25                  if self.code is not None:
     26                          txt += u'\nCode: %s' % self.code
     27                  if self.details is not None:
     28                          txt += u'\n%s' % self.details
     29                  return txt
     30          #----------------------------------
     31 -        def __repr__(self):
     32                  txt = self.errmsg
     33                  if self.source is not None:
     34                          txt += u'\nSource: %s' % source
     35                  if self.code is not None:
     36                          txt += u'\nCode: %s' % self.code
     37                  if self.details is not None:
     38                          txt += u'\n%s' % self.details
     39                  return txt
     40
     41  #------------------------------------------------------------
     42 -class DatabaseObjectInUseError(Exception):
     43 -        def __init__(self, msg):
     44                  self.errmsg = msg
     45
     46 -        def __str__(self):
     47                  return self.errmsg
     48
     49
     50 -class ConnectionError(Exception):
     51          #raised whenever the database backend connection fails
     52 -        def __init__(self, errmsg):
     53                  self.errmsg=errmsg
     54
     55 -        def __str__(self):
     56                  return self.errmsg
     57
     58 -class ConfigError(Exception):
     59          #raised whenever a configuration error occurs
     60 -        def __init__(self, errmsg):
     61                  self.errmsg=errmsg
     62
     63 -        def __str__(self):
     64                  return self.errmsg
     65
     66
     67
     68 -class NoGuiError(Exception):
     69 -        def __init__(self, errmsg):
     70                  self.errmsg=errmsg
     71
     72 -        def __str__(self):
     73                  return self.errmsg
     74
     75
     76 -class PureVirtualFunction(Exception):
     77          #raised whenever the database backend connection fails
     78 -        def __init__(self, errmsg=None):
     79                  if errmsg is not None:
     80                          self.errmsg=errmsg
     81                  else:
     82                          self.errmsg="Attempt to call a pure virtual function!"
     83
     84 -        def __str__(self):
     85                  return self.errmsg
     86
     87  #------------------------------------------------------------
     88  # constructor errors
     89 -class ConstructorError(Exception):
     90          """Raised when a constructor fails."""
     91 -        def __init__(self, errmsg = None):
     92                  if errmsg is None:
     93                          self.errmsg = "%s.__init__() failed" % self.__class__.__name__
     94                  else:
     95                          self.errmsg = errmsg
     96 -        def __str__(self):
     97                  return self.errmsg
     98
     99  # business DB-object exceptions
    100 -class NoSuchBusinessObjectError(ConstructorError):
    101          """Raised when a business db-object can not be found."""
    102 -        def __init__(self, errmsg = None):
    103                  if errmsg is None:
    104                          self.errmsg = "no such business DB-object found"
    105                  else:
    106                          self.errmsg = errmsg
    107 -        def __str__(self):
    108                  return self.errmsg
    109
    110  #------------------------------------------------------------
    111 -class InvalidInputError(Exception):
    112          """Raised by business layers when an attempt is made to input
    113          invalid data"""
    114 -        def __init__(self, errmsg = None):
    115                  if errmsg is None:
    116                          self.errmsg = "%s.__init__() failed" % self.__class__.__name__
    117                  else:
    118                          self.errmsg = errmsg
    119
    120 -        def __str__(self):
    121                  return self.errmsg
    122
    123  #=====================================================================
    124