source: fedd/federation/service_error.py @ ee7f7e4

axis_examplecompt_changesinfo-ops
Last change on this file since ee7f7e4 was e83f2f2, checked in by Ted Faber <faber@…>, 14 years ago

Move proofs around. Lots of changes, including fault handling.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1#!/usr/local/bin/python
2
3# This is used to make the service error reporting independent of the
4# transport.  The XMLRPC and SOAP dispatchers will convert it into
5# transport-specific errors
6class service_error(RuntimeError):
7    access = 1
8    protocol= 2
9    req = 3
10    server_config = 4
11    internal = 5
12    partial = 6
13    federant = 7
14    connect = 8
15    code_str = { 
16        access : "Access Denied",
17        protocol : "Protocol Error",
18        req : "Badly Formed Request",
19        server_config: "Server Configuration Error",
20        internal : "Internal Error",
21        partial: "Partial Embedding",
22        federant: "Federant Error",
23        connect: "Connection Error",
24    }
25    str_code = dict([ (v, k) for k, v in code_str.iteritems() ])
26    client_errors = ( req, partial)
27    server_errors = ( access, protocol, server_config, internal,
28            federant, connect)
29
30    def __init__(self, code=None, desc=None, from_string=None, proof=None):
31        self.code = code
32        self.desc = desc
33        self.proof = proof or []
34        if not isinstance (self.proof, list): self.proof = [ proof ]
35        if code == None:
36            self.set_code_from_string(from_string)
37        RuntimeError.__init__(self, desc)
38
39    def code_string(self, code=None):
40        code = code or self.code
41        return service_error.code_str.get(code)
42   
43    def set_code_from_string(self, errstr):
44        self.code = service_error.str_code.get(errstr, service_error.internal)
45        return self.code
46   
47    def is_client_error(self):
48        return self.code in service_error.client_errors
49
50    def is_server_error(self):
51        return self.code in service_error.server_errors
Note: See TracBrowser for help on using the repository browser.