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
14 class PLCFault(xmlrpclib.Fault):
15 def __init__(self, faultCode, faultString, extra = None):
17 faultString += ": " + extra
18 xmlrpclib.Fault.__init__(self, faultCode, faultString)
20 class PLCInvalidAPIMethod(PLCFault):
21 def __init__(self, method, role = None, extra = None):
22 faultString = "Invalid method " + method
24 faultString += " for role " + role
25 PLCFault.__init__(self, 100, faultString, extra)
27 class PLCInvalidArgumentCount(PLCFault):
28 def __init__(self, got, min, max = min, extra = None):
30 expected = "%d-%d" % (min, max)
33 faultString = "Expected %s arguments, got %d" % \
35 PLCFault.__init__(self, 101, faultString, extra)
37 class PLCInvalidArgument(PLCFault):
38 def __init__(self, extra = None, name = None):
40 faultString = "Invalid %s value" % name
42 faultString = "Invalid argument"
43 PLCFault.__init__(self, 102, faultString, extra)
45 class PLCAuthenticationFailure(PLCFault):
46 def __init__(self, extra = None):
47 faultString = "Failed to authenticate call"
48 PLCFault.__init__(self, 103, faultString, extra)
50 class PLCDBError(PLCFault):
51 def __init__(self, extra = None):
52 faultString = "Database error"
53 PLCFault.__init__(self, 106, faultString, extra)
55 class PLCPermissionDenied(PLCFault):
56 def __init__(self, extra = None):
57 faultString = "Permission denied"
58 PLCFault.__init__(self, 108, faultString, extra)
60 class PLCNotImplemented(PLCFault):
61 def __init__(self, extra = None):
62 faultString = "Not fully implemented"
63 PLCFault.__init__(self, 109, faultString, extra)
65 class PLCAPIError(PLCFault):
66 def __init__(self, extra = None):
67 faultString = "Internal API error"
68 PLCFault.__init__(self, 111, faultString, extra)