source: fedd/federation/service_error.py @ e087a7a

axis_examplecompt_changesinfo-opsversion-1.30version-2.00version-3.01version-3.02
Last change on this file since e087a7a was 5d3f239, checked in by Ted Faber <faber@…>, 16 years ago

change package name to avoid conflicts with fedd on install

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[ef36c1e]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
[058f58e]8    protocol= 2
[ef36c1e]9    req = 3
10    server_config = 4
11    internal = 5
[3441fe3]12    partial = 6
13    federant = 7
[ef36c1e]14    code_str = { 
15        access : "Access Denied",
[058f58e]16        protocol : "Protocol Error",
[ef36c1e]17        req : "Badly Formed Request",
18        server_config: "Server Configuration Error",
[3441fe3]19        internal : "Internal Error",
20        partial: "Partial embedding",
21        federant: "Federant error"
[ef36c1e]22    }
23    str_code = dict([ (v, k) for k, v in code_str.iteritems() ])
24    client_errors = ( req )
[058f58e]25    server_errors = ( access, protocol, server_config, internal)
[ef36c1e]26
27    def __init__(self, code=None, desc=None, from_string=None):
28        self.code = code
29        self.desc = desc
30        if code == None:
31            self.set_code_from_string(from_string)
32        RuntimeError.__init__(self, desc)
33
34    def code_string(self, code=None):
35        code = code or self.code
36        return service_error.code_str.get(code)
37   
38    def set_code_from_string(self, errstr):
39        self.code = service_error.str_code.get(errstr, service_error.internal)
40        return self.code
41   
42    def is_client_error(self):
43        return self.code in service_error.client_errors
44
45    def is_server_error(self):
46        return self.code in service_error.server_errors
Note: See TracBrowser for help on using the repository browser.