Package advene :: Package model :: Package backends :: Module exceptions
[hide private]
[frames] | no frames]

Source Code for Module advene.model.backends.exceptions

 1  # backend related exceptions 
 2   
3 -class WrongFormat(Exception):
4 """ 5 I am raised whenever a backend is badly formatted. 6 """ 7 pass
8
9 -class NoSuchPackage(Exception):
10 """ 11 I am raised whenever a backend is required for an inexisting package. 12 """ 13 pass
14
15 -class PackageInUse(Exception):
16 """ 17 I am raised whenever an attempt is made to bind a Package instance to a 18 backend already bound, or to create an existing (bound or not) Package. 19 The message can either be the other Package instance, if available, or the 20 package backend url. 21 """
22 - def __str__ (self):
23 if isinstance(self.message, basestring): 24 return self.message 25 else: 26 return self.message._id # a package instance
27 pass
28
29 -class InternalError(Exception):
30 """I am raised whenever a backend encounters an internal error. 31 32 I wrap the original exception, if any, as my second argument. 33 """
34 - def __init__(self, msg, original_exception=None, *args):
35 self.args = (msg, original_exception) + args
36 - def __str__(self):
37 return "%s\nOriginal message:\n%s" % self.args[:2]
38 39 # utility class 40
41 -class ClaimFailure(object):
42 """Failure code of a claims_for_* method. 43 44 A ClaimFailure always has a False truth value. Furthermore, it has an 45 ``exception`` attribute containing, if not None, an exception explaining 46 the failure. 47 """ 48
49 - def __init__(self, exception=None):
50 self.exception = exception
51
52 - def __nonzero__(self):
53 return False
54
55 - def __repr__(self):
56 return "ClaimFailure(%r)" % self.exception
57