-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathexceptions.py
More file actions
25 lines (17 loc) · 762 Bytes
/
exceptions.py
File metadata and controls
25 lines (17 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# -*- coding: utf-8 -*-
# Copyright <YEAR(S)> <AUTHOR(S)>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openerp import _, exceptions
class ModuleNameValidationError(exceptions.ValidationError):
"""Base class for this module's validation errors."""
def __init__(self, *args, **kwargs):
self._args, self._kwargs = args, kwargs
value = self._message()
super(ModuleNameValidationError, self).__init__(value)
def _message(self):
"""Format the message."""
return self.__doc__.format(*self._args, **self._kwargs)
class WrongNameError(ModuleNameValidationError):
"""Name {} is wrong."""
class TranslatedWrongNameError(ModuleNameValidationError):
__doc__ = _("Name {} is wrong.")