source: fedd/service_error.py @ 6679c122

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

split out project creation

  • Property mode set to 100644
File size: 1.2 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    code_str = { 
13        access : "Access Denied",
14        proxy : "Proxy Error",
15        req : "Badly Formed Request",
16        server_config: "Server Configuration Error",
17        internal : "Internal Error"
18    }
19    str_code = dict([ (v, k) for k, v in code_str.iteritems() ])
20    client_errors = ( req )
21    server_errors = ( access, proxy, server_config, internal)
22
23    def __init__(self, code=None, desc=None, from_string=None):
24        self.code = code
25        self.desc = desc
26        if code == None:
27            self.set_code_from_string(from_string)
28        RuntimeError.__init__(self, desc)
29
30    def code_string(self, code=None):
31        code = code or self.code
32        return service_error.code_str.get(code)
33   
34    def set_code_from_string(self, errstr):
35        self.code = service_error.str_code.get(errstr, service_error.internal)
36        return self.code
37   
38    def is_client_error(self):
39        return self.code in service_error.client_errors
40
41    def is_server_error(self):
42        return self.code in service_error.server_errors
Note: See TracBrowser for help on using the repository browser.