source: fedd/service_error.py @ 3441fe3

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

closer to fedd integration

  • Property mode set to 100644
File size: 1.3 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    proxy= 2
9    req = 3
10    server_config = 4
11    internal = 5
12    partial = 6
13    federant = 7
14    code_str = { 
15        access : "Access Denied",
16        proxy : "Proxy Error",
17        req : "Badly Formed Request",
18        server_config: "Server Configuration Error",
19        internal : "Internal Error",
20        partial: "Partial embedding",
21        federant: "Federant error"
22    }
23    str_code = dict([ (v, k) for k, v in code_str.iteritems() ])
24    client_errors = ( req )
25    server_errors = ( access, proxy, server_config, internal)
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.