Adapt error message accordingly.
[odoo/odoo.git] / openerp / exceptions.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2011 OpenERP s.a. (<http://openerp.com>).
6 #
7 #    This program is free software: you can redistribute it and/or modify
8 #    it under the terms of the GNU Affero General Public License as
9 #    published by the Free Software Foundation, either version 3 of the
10 #    License, or (at your option) any later version.
11 #
12 #    This program is distributed in the hope that it will be useful,
13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #    GNU Affero General Public License for more details.
16 #
17 #    You should have received a copy of the GNU Affero General Public License
18 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 #
20 ##############################################################################
21
22 """ OpenERP core exceptions.
23
24 This module defines a few exception types. Those types are understood by the
25 RPC layer. Any other exception type bubbling until the RPC layer will be
26 treated as a 'Server error'.
27
28 """
29
30 class Warning(Exception):
31     pass
32
33 class AccessDenied(Exception):
34     """ Login/password error. No message, no traceback. """
35     def __init__(self):
36         super(AccessDenied, self).__init__('Access denied.')
37         self.traceback = ('', '', '')
38
39 class AccessError(Exception):
40     """ Access rights error. """
41
42 class DeferredException(Exception):
43     """ Exception object holding a traceback for asynchronous reporting.
44
45     Some RPC calls (database creation and report generation) happen with
46     an initial request followed by multiple, polling requests. This class
47     is used to store the possible exception occuring in the thread serving
48     the first request, and is then sent to a polling request.
49
50     ('Traceback' is misleading, this is really a exc_info() triple.)
51     """
52     def __init__(self, msg, tb):
53         self.message = msg
54         self.traceback = tb
55
56 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: