Package Ganga :: Package Core :: Module exceptions
[hide private]
[frames] | no frames]

Source Code for Module Ganga.Core.exceptions

  1  ################################################################################ 
  2  # Ganga Project. http://cern.ch/ganga 
  3  # 
  4  # $Id: exceptions.py,v 1.2 2008-09-09 14:37:16 moscicki Exp $ 
  5  ################################################################################ 
  6   
  7   
8 -class GangaException(Exception):
9 """ Markup base class for well-behaved exception that should not print the whole traceback to user's prompt 10 Any subclass of this exception is handled by a custom IPython exception handler 11 and is printed out in an usable format to iPython prompt 12 """ 13
14 - def __init__(self,*args,**kwds):
15 Exception.__init__(self,*args) 16 self.kwds = kwds
17
18 - def __str__(self):
19 """ 20 String representation of this class 21 """ 22 _str = "%s: " % self.__class__.__name__ 23 if hasattr(self,'args') and self.args: 24 _str +=" %s" % str(self.args) 25 if hasattr(self,'kwds') and self.kwds: 26 _str +=" %s" % str(self.kwds) 27 return _str
28
29 -class ApplicationConfigurationError(GangaException):
30 - def __init__(self,excpt,message):
31 GangaException.__init__(self,excpt,message) 32 self.message = message 33 self.excpt = excpt
34
35 - def __str__(self):
36 if self.excpt: 37 e = '(%s:%s)'%(str(type(self.excpt)),str(self.excpt)) 38 else: 39 e = '' 40 return "ApplicationConfigurationError: %s %s"%(self.message,e)
41
42 -class BackendError(GangaException):
43 - def __init__(self,backend_name,message):
44 GangaException.__init__(self,backend_name,message) 45 self.backend_name = backend_name 46 self.message = message
47
48 - def __str__(self):
49 return "BackendError: %s (%s backend) "%(self.message,self.backend_name)
50 51 52 # Exception raised by the Ganga Repository
53 -class RepositoryError(GangaException):
54 """ 55 For non-bulk operations this exception may contain an original 56 exception 'e' raised by the DB client. 57 """
58 - def __init__(self, e = None, msg = None, details = None):
59 if msg == None: 60 msg = "RepositoryError: %s" % str(e) 61 GangaException.__init__(self, msg) 62 self.e = e 63 self.details = details
64
65 - def getOriginalMDError(self):
66 return self.e
67 68 69 # Exception raised by the Ganga Repository
70 -class BulkOperationRepositoryError(RepositoryError):
71 """ 72 For bulk operations this exception 73 have a non-empty dictionary 'details' 74 which contains ids of failed jobs as keys and 'original' exceptions as values. 75 """
76 - def __init__(self, details = None, msg = None):
77 if msg == None: 78 msg = "RepositoryError: %s"% str(e) 79 RepositoryError.__init__(self, msg = msg, details = details) 80 if details == None: 81 self.details = {}
82
83 - def listFailedJobs(self):
84 return self.details.keys()
85
86 - def getOriginalJobError(self, id):
87 return self.details.get(id)
88
89 -class IncompleteJobSubmissionError(GangaException):
90 - def __init__(self,*args):
92
93 -class IncompleteKillError(GangaException):
94 - def __init__(self,*args):
96
97 -class JobManagerError(GangaException):
98 - def __init__(self,msg):
99 self.msg = msg 100 GangaException.__init__(self,msg)
101
102 - def __str__(self):
103 return "JobManagerError: %s" % str(self.msg)
104
105 -class GangaAttributeError(AttributeError,GangaException):
106 - def __init__(self,*a,**k): AttributeError.__init__(self,*a,**k)
107
108 -class GangaValueError(ValueError,GangaException):
109 - def __init__(self,*a,**k): ValueError.__init__(self,*a,**k)
110
111 -class ProtectedAttributeError(GangaAttributeError):
112 'Attribute is read-only and may not be modified by the user (for example job.id)'
113 - def __init__(self,*a,**k): GangaAttributeError.__init__(self,*a,**k)
114 115
116 -class ReadOnlyObjectError(GangaAttributeError):
117 'Object cannot be modified (for example job in a submitted state)'
118 - def __init__(self,*a,**k): GangaAttributeError.__init__(self,*a,**k)
119 120
121 -class TypeMismatchError(GangaAttributeError):
122 - def __init__(self,*a,**k): GangaAttributeError.__init__(self,*a,**k)
123 124
125 -class SchemaError(GangaAttributeError):
126 - def __init__(self,*a,**k): GangaAttributeError.__init__(self,*a,**k)
127 128 # 129 # 130 # $Log: not supported by cvs2svn $ 131 # Revision 1.1 2008/07/17 16:40:49 moscicki 132 # migration of 5.0.2 to HEAD 133 # 134 # the doc and release/tools have been taken from HEAD 135 # 136 # Revision 1.20.4.1 2008/03/04 14:49:03 amuraru 137 # make RepositoryError a GangaException 138 # 139 # Revision 1.20 2007/09/13 08:36:20 amuraru 140 # fixed the _str_ method of GangaException 141 # 142 # Revision 1.19 2007/09/12 16:25:09 amuraru 143 # - log user exceptions using specific loggers 144 # - fixed the str repr in exceptions 145 # 146 # Revision 1.18 2007/03/26 16:10:47 moscicki 147 # formating of exception messages 148 # 149 # Revision 1.17 2007/02/28 18:23:59 moscicki 150 # moved GangaException here (it now inherits from Exception) 151 # 152 # Revision 1.16 2007/02/22 13:25:29 moscicki 153 # define JobManager exception here 154 # 155 # Revision 1.15 2006/10/26 12:31:34 moscicki 156 # minor repository exception changes 157 # 158 # Revision 1.14 2006/08/11 13:41:54 moscicki 159 # better formatting of messages 160 # 161 # Revision 1.13 2006/07/10 14:02:00 moscicki 162 # IncompleteKillError 163 # 164 # Revision 1.12 2006/02/10 14:07:42 moscicki 165 # __str__ for ApplicationConfigurationError 166 # 167 # Revision 1.11 2005/12/02 15:23:11 moscicki 168 # IcompleteJobSubmission 169 # 170 # Revision 1.10 2005/08/23 17:20:59 moscicki 171 # *** empty log message *** 172 # 173 # Revision 1.9 2005/08/23 17:20:33 moscicki 174 # *** empty log message *** 175 # 176 # 177 # 178