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
12 class PLCFault(xmlrpclib.Fault):
13 def __init__(self, faultCode, faultString, extra = None):
15 faultString += ": " + extra
16 xmlrpclib.Fault.__init__(self, faultCode, faultString)
18 class PLCInvalidAPIMethod(PLCFault):
19 def __init__(self, method, role = None, extra = None):
20 faultString = "Invalid method " + method
22 faultString += " for role " + role
23 PLCFault.__init__(self, 100, faultString, extra)
25 class PLCInvalidArgumentCount(PLCFault):
26 def __init__(self, got, min, max = min, extra = None):
28 expected = "%d-%d" % (min, max)
31 faultString = "Expected %s arguments, got %d" % \
33 PLCFault.__init__(self, 101, faultString, extra)
35 class PLCInvalidArgument(PLCFault):
36 def __init__(self, extra = None, name = None):
38 faultString = "Invalid %s value" % name
40 faultString = "Invalid argument"
41 PLCFault.__init__(self, 102, faultString, extra)
43 class PLCAuthenticationFailure(PLCFault):
44 def __init__(self, extra = None):
45 faultString = "Failed to authenticate call"
46 PLCFault.__init__(self, 103, faultString, extra)
48 class PLCDBError(PLCFault):
49 def __init__(self, extra = None):
50 faultString = "Database error"
51 PLCFault.__init__(self, 106, faultString, extra)
53 class PLCPermissionDenied(PLCFault):
54 def __init__(self, extra = None):
55 faultString = "Permission denied"
56 PLCFault.__init__(self, 108, faultString, extra)
58 class PLCNotImplemented(PLCFault):
59 def __init__(self, extra = None):
60 faultString = "Not fully implemented"
61 PLCFault.__init__(self, 109, faultString, extra)
63 class PLCAPIError(PLCFault):
64 def __init__(self, extra = None):
65 faultString = "Internal API error"
66 PLCFault.__init__(self, 111, faultString, extra)