Exceptions¶
All Vodoo exceptions inherit from VodooError, allowing consumers to catch a single base class.
The Odoo server-side exceptions (OdooUserError and subclasses) mirror the hierarchy from odoo/exceptions.py. When the transport layer receives an error whose data.name matches a known Odoo exception, it raises the corresponding Vodoo exception — so you can handle specific failure modes without parsing error strings.
VodooError
├── ConfigurationError
├── AuthenticationError
├── RecordNotFoundError
├── RecordOperationError
├── TransportError
│ └── OdooUserError ← odoo.exceptions.UserError
│ ├── OdooAccessDeniedError ← odoo.exceptions.AccessDenied
│ ├── OdooAccessError ← odoo.exceptions.AccessError
│ ├── OdooMissingError ← odoo.exceptions.MissingError
│ └── OdooValidationError ← odoo.exceptions.ValidationError
└── FieldParsingError
Usage¶
from vodoo import (
VodooError,
AuthenticationError,
TransportError,
RecordNotFoundError,
)
from vodoo.exceptions import (
OdooAccessError,
OdooValidationError,
OdooMissingError,
)
try:
client.write("res.partner", [999999], {"name": "test"})
except OdooAccessError:
print("You don't have permission for this operation")
except OdooMissingError:
print("Record no longer exists")
except OdooValidationError as e:
print(f"Constraint violated: {e}")
except RecordNotFoundError as e:
print(f"Not found: {e.model} #{e.record_id}")
except TransportError as e:
print(f"RPC error [{e.code}]: {e}")
except VodooError:
print("Something else went wrong")
TypeScript: rejected or unknown outcome¶
The TypeScript SDK separates two cases. Use them to decide if a write can be sent again.
- Rejected:
TransportErrorand itsOdoo*Errorsubclasses. Odoo answered with an error, and Odoo normally rolled back the call. - Unknown:
UncertainOutcomeError. Odoo can have applied the call. Read the affected records before you send the write again.
VodooError
├── TransportError ← Odoo answered with an error (normally rolled back)
│ └── OdooUserError …
└── UncertainOutcomeError ← outcome unknown; property `reason`
├── NetworkError ← reason "timeout" or "network"
└── HttpStatusError ← reason "http_status"; property `status`
reason |
Cause |
|---|---|
"timeout" |
The request timed out or was aborted. |
"network" |
fetch() threw, or the response body could not be read. |
"http_status" |
A non-2xx response without an Odoo error body: a proxy 502, 503, or 504, an HTML page, a WAF JSON body, or a 3xx redirect. Vodoo never follows redirects. |
"invalid_response" |
A 2xx response with a body that is not JSON, a JSON-RPC body with a non-object error or without result, error, and jsonrpc, or a create result that is not one record ID. |
"commit_unknown" |
Odoo answered with psycopg2.OperationalError, psycopg2.InterfaceError, psycopg2.errors.AdminShutdown, or psycopg2.errors.CrashShutdown: its database connection broke, possibly during COMMIT. |
An Odoo error body is the output of Odoo serialize_exception: name as module.Class, message, arguments, context, and debug (Odoo 17, 18, and 19). JSON-2 sends it as the body; JSON-RPC sends it as error.data. Other JSON bodies are not Odoo errors.
Limit of "rejected": Odoo runs post-commit hooks after COMMIT. If a hook fails, Odoo answers with an error although the data is committed. Vodoo cannot detect this case.
Both the JSON-2 and the legacy JSON-RPC transport use these classes. Vodoo retries only the read methods search, search_read, read, fields_get, and name_search, and only after a NetworkError. It never retries a write.
Version 5.0.0 introduced this split. The TypeScript README lists the breaking changes.
The Python SDK does not have UncertainOutcomeError. In Python, timeouts and network failures raise the httpx2 exceptions, and a JSON-2 non-2xx response raises TransportError with the HTTP status as code.
Reference¶
exceptions
¶
Vodoo exception hierarchy.
All public exceptions inherit from :class:VodooError so that library
consumers can catch a single base class when desired.
The Odoo-server error classes (:class:OdooUserError and its subclasses)
mirror the hierarchy defined in odoo/exceptions.py on the server.
When the transport layer receives a JSON-RPC or JSON-2 error whose
data.name matches a known Odoo exception class, it raises the
corresponding Vodoo exception so callers can handle specific failure
modes without parsing error strings.
Hierarchy overview::
VodooError
├── ConfigurationError
├── AuthenticationError
├── AuthenticationError
├── RecordNotFoundError
├── RecordOperationError
├── RevisionInputError
├── UnverifiableRevisionError
├── StaleRevisionError
├── TransportError
│ └── OdooUserError ← odoo.exceptions.UserError
│ ├── OdooAccessDeniedError ← odoo.exceptions.AccessDenied
│ ├── OdooAccessError ← odoo.exceptions.AccessError
│ ├── OdooMissingError ← odoo.exceptions.MissingError
│ └── OdooValidationError ← odoo.exceptions.ValidationError
└── FieldParsingError
VodooError
¶
Bases: Exception
Base exception for all Vodoo errors.
ConfigurationError
¶
Bases: VodooError
Raised when the configuration is invalid or incomplete.
AuthenticationError
¶
Bases: VodooError
Raised when authentication with the Odoo server fails.
RecordNotFoundError
¶
Bases: VodooError
Raised when an expected Odoo record does not exist.
Source code in src/vodoo/exceptions.py
RecordOperationError
¶
Bases: VodooError
Raised when a write/create/unlink operation fails.
RevisionInputError
¶
Bases: VodooError
An expected write_date is not a canonical UTC seconds timestamp.
UnverifiableRevisionError
¶
Bases: VodooError
A requested best-effort freshness check cannot verify the revision.
StaleRevisionError
¶
Bases: VodooError
A non-atomic preflight observed a stale revision; no mutation was sent.
Source code in src/vodoo/exceptions.py
TransportError
¶
Bases: VodooError
Raised on JSON-RPC / HTTP transport failures.
Carries the numeric error code and the raw data dict returned by the server so that callers can inspect details without string-parsing.
Source code in src/vodoo/exceptions.py
OdooUserError
¶
Bases: TransportError
The server raised odoo.exceptions.UserError.
This is the generic Odoo end-user error — semantically a 400-class problem (bad request / invalid operation given the current state).
Source code in src/vodoo/exceptions.py
OdooAccessDeniedError
¶
Bases: OdooUserError
The server raised odoo.exceptions.AccessDenied.
Login or API-key authentication failed.
Source code in src/vodoo/exceptions.py
OdooAccessError
¶
Bases: OdooUserError
The server raised odoo.exceptions.AccessError.
The authenticated user lacks the required access rights (ACL / record rules) for the attempted operation.
Source code in src/vodoo/exceptions.py
OdooMissingError
¶
Bases: OdooUserError
The server raised odoo.exceptions.MissingError.
The record(s) referenced in the operation no longer exist.
Source code in src/vodoo/exceptions.py
OdooValidationError
¶
Bases: OdooUserError
The server raised odoo.exceptions.ValidationError.
A Python constraint or SQL constraint was violated during create/write.
Source code in src/vodoo/exceptions.py
FieldParsingError
¶
Bases: VodooError
Raised when a field=value assignment cannot be parsed.
transport_error_from_data
¶
transport_error_from_data(message: str, code: int = -1, data: dict[str, Any] | None = None) -> TransportError
Create the most specific :class:TransportError subclass for data.
Inspects data["name"] (set by Odoo's serialize_exception) and
returns an instance of the matching :class:OdooUserError subclass
when possible, falling back to plain :class:TransportError.