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  # @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  #------------------------------------------------------------
    85 -class InvalidInputError(Exception):
    86          """Raised by business layers when an attempt is made to input
    87          invalid data"""
    88 -        def __init__(self, errmsg = None):
    89                  if errmsg is None:
    90                          self.errmsg = "%s.__init__() failed" % self.__class__.__name__
    91                  else:
    92                          self.errmsg = errmsg
    93
    94 -        def __str__(self):
    95                  return self.errmsg
    96
    97  #=====================================================================
    98