Package flumotion :: Package common :: Module errors
[hide private]

Source Code for Module flumotion.common.errors

  1  # -*- Mode: Python -*- 
  2  # vi:si:et:sw=4:sts=4:ts=4 
  3   
  4  # Flumotion - a streaming media server 
  5  # Copyright (C) 2004,2005,2006,2007,2008,2009 Fluendo, S.L. 
  6  # Copyright (C) 2010,2011 Flumotion Services, S.A. 
  7  # All rights reserved. 
  8  # 
  9  # This file may be distributed and/or modified under the terms of 
 10  # the GNU Lesser General Public License version 2.1 as published by 
 11  # the Free Software Foundation. 
 12  # This file is distributed without any warranty; without even the implied 
 13  # warranty of merchantability or fitness for a particular purpose. 
 14  # See "LICENSE.LGPL" in the source distribution for more information. 
 15  # 
 16  # Headers in this file shall remain intact. 
 17   
 18  """exceptions used by Flumotion, serializable and normal 
 19  """ 
 20   
 21  from twisted.spread import pb 
 22   
 23  __version__ = "$Rev$" 
 24   
 25   
26 -class CancelledError(Exception):
27 "An operation was cancelled"
28 29
30 -class OptionError(Exception):
31 "Error in options"
32 33
34 -class ConfigError(Exception):
35 """ 36 Error during parsing of configuration 37 38 args[0]: str 39 """
40 41
42 -class NoProjectError(Exception):
43 """ 44 The given project does not exist 45 46 @ivar projectName: name of the project 47 @type projectName: str 48 @ivar debug: optional additional debug message 49 @type debug: str 50 """ 51
52 - def __init__(self, projectName, debug=None):
53 self.projectName = projectName 54 self.debug = debug 55 # work like a normal Exception too 56 self.args = (projectName, debug)
57 58
59 -class NoSSLError(Exception):
60 "SSL is not available"
61 62 63 # connection errors 64 65
66 -class ConnectionError(pb.Error):
67 "General connection error"
68 69
70 -class NotConnectedError(ConnectionError):
71 "Not connected"
72 73
74 -class NotAuthenticatedError(ConnectionError):
75 "Not authenticated"
76 77
78 -class ConnectionRefusedError(ConnectionError):
79 "Connection refused"
80 81
82 -class ConnectionFailedError(ConnectionError):
83 "Connection failed"
84 85
86 -class ConnectionCancelledError(ConnectionError):
87 "Connection attempt cancelled"
88 89
90 -class ManagerNotConnectedError(NotConnectedError):
91 "Manager not connected"
92 93
94 -class AlreadyConnectingError(ConnectionError):
95 "Already connecting"
96 97
98 -class AlreadyConnectedError(ConnectionError):
99 "Already connected"
100 101
102 -class PipelineParseError(pb.Error):
103 "An error occurred while trying to parse the pipeline"
104 105 106 # remote method errors 107 108
109 -class RemoteMethodError(pb.Error):
110 """ 111 Generic remote method error. 112 113 @ivar methodName: name of the method 114 @type methodName: str 115 @ivar debug: optional additional debug message 116 @type debug: str 117 """ 118
119 - def __init__(self, methodName, debug=None):
120 self.methodName = methodName 121 self.debug = debug 122 # work like a normal Exception too 123 self.args = (methodName, debug)
124 125 # this allows us to decide how it gets serialized 126
127 - def __str__(self):
128 msg = "%s on method '%s'" % (self.__class__.__name__, self.methodName) 129 if self.debug: 130 msg += " (%s)" % self.debug 131 return msg
132 133
134 -class RemoteRunError(RemoteMethodError):
135 "Error while running remote code, before getting a result"
136 137
138 -class RemoteRunFailure(RemoteMethodError):
139 "A remote method generated a failure result"
140 141
142 -class NoMethodError(RemoteMethodError):
143 "The remote method does not exist"
144 145 146 # FIXME: subclass from both entry/bundle and syntax errors ? 147 # FIXME: name ? 148 149
150 -class EntrySyntaxError(pb.Error):
151 "Syntax error while getting entry point in a bundle"
152 153 154 # other errors 155 156
157 -class NotReadyError(pb.Error):
158 "The component is not ready yet"
159 160
161 -class PropertyError(pb.Error):
162 "An error occurred while setting a property on the component"
163 164
165 -class NoPerspectiveError(pb.Error):
166 "The component does not have a perspective"
167 168
169 -class FatalError(pb.Error):
170 "A fatal error"
171 172 # F0.10 173 __pychecker__ = 'no-shadowbuiltin' 174 175
176 -class SystemError(FatalError):
177
178 - def __init__(self, *args, **kwargs):
179 import warnings 180 warnings.warn("Please use builtin SystemError or errors.FatalError", 181 DeprecationWarning, stacklevel=2) 182 pb.Error.__init__(self, *args, **kwargs)
183 __pychecker__ = '' 184 185
186 -class ReloadSyntaxError(pb.Error):
187 "A syntax error during a reload of a module"
188 189
190 -class WrongStateError(pb.Error):
191 "The remote object was in the wrong state for this command"
192 193
194 -class InsufficientPrivilegesError(pb.Error):
195 "You do not have the necessary privileges to complete this operation"
196 197 198 # component errors 199 200
201 -class ComponentError(pb.Error):
202 """ 203 Error while doing something to a component. 204 205 args[0]: ComponentState 206 """
207 208 209 # FIXME: rename, component first 210 211
212 -class SleepingComponentError(ComponentError):
213 "Component is sleeping, cannot handle request"
214 215
216 -class ComponentAlreadyStartingError(ComponentError):
217 "Component told to start, but is already starting"
218 219
220 -class ComponentAlreadyRunningError(ComponentError):
221 "Component told to start, but is already running"
222 223
224 -class ComponentMoodError(ComponentError):
225 "Component is in the wrong mood to perform the given function"
226 227
228 -class ComponentNoWorkerError(ComponentError):
229 "Component does not have its worker available"
230 231
232 -class BusyComponentError(ComponentError):
233 """ 234 Component is busy doing something. 235 236 args[0]: ComponentState 237 args[1]: str 238 """
239 240
241 -class ComponentConfigError(ComponentError):
242 """ 243 An error in the configuration of the component. 244 245 args[0]: ComponentState 246 args[1]: str 247 """
248 249
250 -class ComponentAlreadyExistsError(ComponentError):
251 """ 252 A component name is already used. 253 254 args[0]: L{flumotion.common.common.componentId} 255 """
256 257
258 -class ComponentCreateError(ComponentError):
259 """ 260 An error during creation of a component. Can be raised during a 261 remote_create call on a worker. 262 """
263 264
265 -class HandledException(Exception):
266 """ 267 An exception that has already been adequately handled, but still needs 268 to be propagated to indicate failure to callers. 269 270 This allows callers and defgens to propagate gracefully without 271 doing a traceback, while still doing tracebacks for unhandled exceptions. 272 273 Only argument is the original exception or failure. 274 """
275 276
277 -class ComponentSetupError(ComponentError):
278 """ 279 An error during setup of a component. Can be raised during a 280 remote_setup call on a component. 281 """
282 283
284 -class ComponentStartError(ComponentError):
285 """ 286 An error during starting of a component. Can be raised during a 287 remote_start call on a component. 288 """
289 290
291 -class ComponentSetupHandledError(ComponentSetupError, HandledException):
292 """ 293 An error during setup of a component, that's already handled in a 294 different way (for example, through a message). 295 Can be raised during a remote_setup call on a component. 296 """
297 298
299 -class ComponentStartHandledError(ComponentStartError, HandledException):
300 """ 301 An error during starting of a component, that's already handled in a 302 different way (for example, through a message). 303 Can be raised during a remote_start call on a component. 304 """
305 306
307 -class UnknownComponentError(ComponentError):
308 "A given component or component type does not exist"
309 310
311 -class ComponentValidationError(ComponentError):
312 "The configuration for the component is not valid"
313 314
315 -class UnknownPlugError(pb.Error):
316 "A given plug type does not exist"
317 318 319 # effect errors 320 321
322 -class UnknownEffectError(pb.Error):
323 "A given effect or effect type does not exist"
324 325
326 -class FlumotionError(pb.Error):
327 "Generic Flumotion error"
328 329
330 -class NoBundleError(pb.Error):
331 "The requested bundle was not found"
332 333
334 -class TimeoutException(Exception):
335 "Timed out"
336 337 338 # effect errors 339 340
341 -class PropertyNotModifiableError(pb.Error):
342 "The property cannnot be modified with the component already set-up"
343 344 345 # serializable GStreamer errors 346 347
348 -class GStreamerError(pb.Error):
349 "Generic GStreamer error"
350 351
352 -class GStreamerGstError(GStreamerError):
353 """GStreamer-generated error with source, GError and 354 debug string as args"""
355 356
357 -class MissingElementError(GStreamerError):
358 "A needed element is missing"
359 360
361 -class AccessDeniedError(Exception):
362 "Access is denied to this object, usually a file or directory"
363 364
365 -class NotDirectoryError(Exception):
366 "Access to an object that is not a directory"
367