mirror of
https://github.com/bringout/oca-ocb-core.git
synced 2026-04-21 14:12:06 +02:00
19.0 vanilla
This commit is contained in:
parent
0a7ae8db93
commit
991d2234ca
416 changed files with 646602 additions and 300844 deletions
|
|
@ -1,15 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
"""The Odoo Exceptions module defines a few core 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'.
|
||||
|
||||
.. note::
|
||||
If you consider introducing new exceptions,
|
||||
check out the :mod:`odoo.addons.test_exceptions` module.
|
||||
"""
|
||||
|
||||
|
||||
|
|
@ -17,8 +10,9 @@ class UserError(Exception):
|
|||
"""Generic error managed by the client.
|
||||
|
||||
Typically when the user tries to do something that has no sense given the current
|
||||
state of a record. Semantically comparable to the generic 400 HTTP status codes.
|
||||
state of a record.
|
||||
"""
|
||||
http_status = 422 # Unprocessable Entity
|
||||
|
||||
def __init__(self, message):
|
||||
"""
|
||||
|
|
@ -47,19 +41,38 @@ class AccessDenied(UserError):
|
|||
|
||||
.. note::
|
||||
|
||||
No traceback.
|
||||
Traceback only visible in the logs.
|
||||
|
||||
.. admonition:: Example
|
||||
|
||||
When you try to log with a wrong password.
|
||||
"""
|
||||
http_status = 403 # Forbidden
|
||||
|
||||
def __init__(self, message="Access Denied"):
|
||||
super().__init__(message)
|
||||
self.suppress_traceback() # must be called in `except`s too
|
||||
|
||||
def suppress_traceback(self):
|
||||
"""
|
||||
Remove the traceback, cause and context of the exception, hiding
|
||||
where the exception occured but keeping the exception message.
|
||||
|
||||
This method must be called in all situations where we are about
|
||||
to print this exception to the users.
|
||||
|
||||
It is OK to leave the traceback (thus to *not* call this method)
|
||||
if the exception is only logged in the logs, as they are only
|
||||
accessible by the system administrators.
|
||||
"""
|
||||
self.with_traceback(None)
|
||||
self.__cause__ = None
|
||||
self.traceback = ('', '', '')
|
||||
|
||||
# During handling of the above exception, another exception occurred
|
||||
self.__context__ = None
|
||||
|
||||
# The above exception was the direct cause of the following exception
|
||||
self.__cause__ = None
|
||||
|
||||
class AccessError(UserError):
|
||||
"""Access rights error.
|
||||
|
|
@ -68,6 +81,7 @@ class AccessError(UserError):
|
|||
|
||||
When you try to read a record that you are not allowed to.
|
||||
"""
|
||||
http_status = 403 # Forbidden
|
||||
|
||||
|
||||
class CacheMiss(KeyError):
|
||||
|
|
@ -89,6 +103,17 @@ class MissingError(UserError):
|
|||
|
||||
When you try to write on a deleted record.
|
||||
"""
|
||||
http_status = 404 # Not Found
|
||||
|
||||
|
||||
class LockError(UserError):
|
||||
"""Record(s) could not be locked.
|
||||
|
||||
.. admonition:: Example
|
||||
|
||||
Code tried to lock records, but could not succeed.
|
||||
"""
|
||||
http_status = 409 # Conflict
|
||||
|
||||
|
||||
class ValidationError(UserError):
|
||||
|
|
@ -98,3 +123,15 @@ class ValidationError(UserError):
|
|||
|
||||
When you try to create a new user with a login which already exist in the db.
|
||||
"""
|
||||
|
||||
|
||||
class ConcurrencyError(Exception):
|
||||
"""
|
||||
Signal that two concurrent transactions tried to commit something
|
||||
that violates some constraint. Signal that the transaction that
|
||||
failed should be retried after a short delay, see
|
||||
:func:`~odoo.service.model.retrying`.
|
||||
|
||||
This exception is low-level and has very few use cases, it should
|
||||
only be used if all alternatives are deemed worse.
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue