2 # PLCAPI XML-RPC faults
4 # Aaron Klingaman <alk@absarokasoft.com>
5 # Mark Huang <mlhuang@cs.princeton.edu>
7 # Copyright (C) 2004-2006 The Trustees of Princeton University
8 # $Id: Faults.py,v 1.2 2006/12/07 09:13:55 thierry Exp $
13 class PLCFault(xmlrpclib.Fault):
14 def __init__(self, faultCode, faultString, extra = None):
16 faultString += ": " + extra
17 xmlrpclib.Fault.__init__(self, faultCode, faultString)
19 class PLCInvalidAPIMethod(PLCFault):
20 def __init__(self, method, role = None, extra = None):
21 faultString = "Invalid method " + method
23 faultString += " for role " + role
24 PLCFault.__init__(self, 100, faultString, extra)
26 class PLCInvalidArgumentCount(PLCFault):
27 def __init__(self, got, min, max = min, extra = None):
29 expected = "%d-%d" % (min, max)
32 faultString = "Expected %s arguments, got %d" % \
34 PLCFault.__init__(self, 101, faultString, extra)
36 class PLCInvalidArgument(PLCFault):
37 def __init__(self, extra = None, name = None):
39 faultString = "Invalid %s value" % name
41 faultString = "Invalid argument"
42 PLCFault.__init__(self, 102, faultString, extra)
44 class PLCAuthenticationFailure(PLCFault):
45 def __init__(self, extra = None):
46 faultString = "Failed to authenticate call"
47 PLCFault.__init__(self, 103, faultString, extra)
49 class PLCDBError(PLCFault):
50 def __init__(self, extra = None):
51 faultString = "Database error"
52 PLCFault.__init__(self, 106, faultString, extra)
54 class PLCPermissionDenied(PLCFault):
55 def __init__(self, extra = None):
56 faultString = "Permission denied"
57 PLCFault.__init__(self, 108, faultString, extra)
59 class PLCNotImplemented(PLCFault):
60 def __init__(self, extra = None):
61 faultString = "Not fully implemented"
62 PLCFault.__init__(self, 109, faultString, extra)
64 class PLCAPIError(PLCFault):
65 def __init__(self, extra = None):
66 faultString = "Internal API error"
67 PLCFault.__init__(self, 111, faultString, extra)