[IMP] introduce a new type of exception: WarningConfig. Note that no corresponding RPC_FAULT_CODE has been added; WarningConfig will share the same RPC_FAULT_CODE than Warning (RPC_FAULT_CODE_WARNING = 2)
Also remove a few whitespaces bzr revid: abo@openerp.com-20130118152346-5v4j94wjrq34hq4m
This commit is contained in:
parent
a075983249
commit
8bd622202b
|
@ -27,9 +27,17 @@ treated as a 'Server error'.
|
|||
|
||||
"""
|
||||
|
||||
import re
|
||||
|
||||
class Warning(Exception):
|
||||
pass
|
||||
|
||||
class WarningConfig(Exception):
|
||||
""" Warning bound to a misconfiguration. """
|
||||
def __init__(self, msg):
|
||||
# todo: treat the msg (regex)
|
||||
super(WarningConfig, self).__init__(msg)
|
||||
|
||||
class AccessDenied(Exception):
|
||||
""" Login/password error. No message, no traceback. """
|
||||
def __init__(self):
|
||||
|
|
|
@ -306,6 +306,8 @@ def dispatch_rpc(service_name, method, params):
|
|||
raise
|
||||
except openerp.exceptions.Warning:
|
||||
raise
|
||||
except openerp.exceptions.WarningConfig:
|
||||
raise
|
||||
except openerp.exceptions.DeferredException, e:
|
||||
_logger.exception(tools.exception_to_unicode(e))
|
||||
post_mortem(e.traceback)
|
||||
|
|
|
@ -170,6 +170,8 @@ def netrpc_handle_exception_legacy(e):
|
|||
return 'warning -- ' + e.name + '\n\n' + e.value
|
||||
if isinstance(e, openerp.exceptions.Warning):
|
||||
return 'warning -- Warning\n\n' + str(e)
|
||||
if isinstance(e, openerp.exceptions.WarningConfig):
|
||||
return 'warning -- Warning\n\n' + str(e)
|
||||
if isinstance(e, openerp.exceptions.AccessError):
|
||||
return 'warning -- AccessError\n\n' + str(e)
|
||||
if isinstance(e, openerp.exceptions.AccessDenied):
|
||||
|
|
|
@ -95,6 +95,8 @@ def xmlrpc_handle_exception(e):
|
|||
response = xmlrpclib.dumps(fault, allow_none=False, encoding=None)
|
||||
elif isinstance(e, openerp.exceptions.Warning):
|
||||
fault = xmlrpclib.Fault(RPC_FAULT_CODE_WARNING, str(e))
|
||||
elif isinstance(e, openerp.exceptions.WarningConfig):
|
||||
fault = xmlrpclib.Fault(RPC_FAULT_CODE_WARNING, str(e))
|
||||
response = xmlrpclib.dumps(fault, allow_none=False, encoding=None)
|
||||
elif isinstance (e, openerp.exceptions.AccessError):
|
||||
fault = xmlrpclib.Fault(RPC_FAULT_CODE_ACCESS_ERROR, str(e))
|
||||
|
|
Loading…
Reference in New Issue