Skip to main content
The SDK raises typed exceptions whenever the API returns an error response. Every exception extends MoleculeError, so you can catch the base class for a broad handler or catch specific subclasses to handle individual failure modes precisely. All error classes are importable directly from the top-level molecule package.

Error Hierarchy

Error Attributes

Every MoleculeError instance carries four attributes that surface context from the API response. Access these attributes on any caught exception:

Error Code Reference

Handling Common Cases

The following pattern covers the most common failure modes when submitting orders. Adapt the retry and fallback logic to your execution requirements.
All error classes — including MoleculeError and every subclass — are exported from the top-level molecule package. Import them with from molecule import UnauthorizedError, ConflictError, ... rather than from internal submodules.