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