X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=openerp%2Fexceptions.py;h=6e5d4448451e8f7d4fcc1836141a4cad5e7b1521;hb=9964aae7a3e5572e1e6f598408566ef8017a106c;hp=387e126b8c4ee54d5e2752762dd8e5f04ff6819e;hpb=8bd622202b123b4919ca7862b92d4fe19d5f464b;p=odoo%2Fodoo.git diff --git a/openerp/exceptions.py b/openerp/exceptions.py index 387e126..6e5d444 100644 --- a/openerp/exceptions.py +++ b/openerp/exceptions.py @@ -25,18 +25,28 @@ This module defines a few exception types. Those types are understood by the RPC layer. Any other exception type bubbling until the RPC layer will be treated as a 'Server error'. +If you consider introducing new exceptions, check out the test_exceptions addon. """ -import re +# kept for backward compatibility +class except_orm(Exception): + def __init__(self, name, value): + self.name = name + self.value = value + self.args = (name, value) 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 RedirectWarning(Exception): + """ Warning with a possibility to redirect the user instead of simply + diplaying the warning message. + + Should receive as parameters: + :param int action_id: id of the action where to perform the redirection + :param string button_text: text to put on the button that will trigger + the redirection. + """ class AccessDenied(Exception): """ Login/password error. No message, no traceback. """ @@ -44,8 +54,19 @@ class AccessDenied(Exception): super(AccessDenied, self).__init__('Access denied.') self.traceback = ('', '', '') -class AccessError(Exception): +class AccessError(except_orm): """ Access rights error. """ + def __init__(self, msg): + super(AccessError, self).__init__('AccessError', msg) + +class MissingError(except_orm): + """ Missing record(s). """ + def __init__(self, msg): + super(MissingError, self).__init__('MissingError', msg) + +class ValidationError(except_orm): + def __init__(self, msg): + super(ValidationError, self).__init__('ValidateError', msg) class DeferredException(Exception): """ Exception object holding a traceback for asynchronous reporting.