Source code for arango.exceptions

from typing import Optional

from arango.request import Request
from arango.response import Response


[docs]class ArangoError(Exception): """Base class for all exceptions in python-arango."""
[docs]class ArangoClientError(ArangoError): """Base class for errors originating from python-arango client. :param msg: Error message. :type msg: str :cvar source: Source of the error (always set to "client"). :vartype source: str :ivar message: Error message. :vartype message: str """ source = "client" def __init__(self, msg: str) -> None: super().__init__(msg) self.message = msg self.error_message = None self.error_code = None self.url = None self.response = None self.request = None self.http_method = None self.http_code = None self.http_headers = None
[docs]class ArangoServerError(ArangoError): """Base class for errors originating from ArangoDB server. :param resp: HTTP response. :type resp: arango.response.Response :param msg: Error message override. :type msg: str :cvar source: Source of the error (always set to "server"). :vartype source: str :ivar message: Exception message. :vartype message: str :ivar url: API URL. :vartype url: str :ivar response: HTTP response object. :vartype response: arango.response.Response :ivar request: HTTP request object. :vartype request: arango.request.Request :ivar http_method: HTTP method in lowercase (e.g. "post"). :vartype http_method: str :ivar http_code: HTTP status code. :vartype http_code: int :ivar http_headers: Response headers. :vartype http_headers: dict :ivar error_code: Error code from ArangoDB server. :vartype error_code: int :ivar error_message: Raw error message from ArangoDB server. :vartype error_message: str """ source = "server" def __init__( self, resp: Response, request: Request, msg: Optional[str] = None ) -> None: msg = msg or resp.error_message or resp.status_text self.error_message = resp.error_message self.error_code = resp.error_code if self.error_code is not None: msg = f"[HTTP {resp.status_code}][ERR {self.error_code}] {msg}" else: msg = f"[HTTP {resp.status_code}] {msg}" self.error_code = resp.status_code super().__init__(msg) self.message = msg self.url = resp.url self.response = resp self.request = request self.http_method = resp.method self.http_code = resp.status_code self.http_headers = resp.headers
################## # AQL Exceptions # ##################
[docs]class AQLQueryListError(ArangoServerError): """Failed to retrieve running AQL queries."""
[docs]class AQLQueryExplainError(ArangoServerError): """Failed to parse and explain query."""
[docs]class AQLQueryValidateError(ArangoServerError): """Failed to parse and validate query."""
[docs]class AQLQueryExecuteError(ArangoServerError): """Failed to execute query."""
[docs]class AQLQueryKillError(ArangoServerError): """Failed to kill the query."""
[docs]class AQLQueryClearError(ArangoServerError): """Failed to clear slow AQL queries."""
[docs]class AQLQueryTrackingGetError(ArangoServerError): """Failed to retrieve AQL tracking properties."""
[docs]class AQLQueryTrackingSetError(ArangoServerError): """Failed to configure AQL tracking properties."""
[docs]class AQLCachePropertiesError(ArangoServerError): """Failed to retrieve query cache properties."""
[docs]class AQLCacheConfigureError(ArangoServerError): """Failed to configure query cache properties."""
[docs]class AQLCacheEntriesError(ArangoServerError): """Failed to retrieve AQL cache entries."""
[docs]class AQLCacheClearError(ArangoServerError): """Failed to clear the query cache."""
[docs]class AQLFunctionListError(ArangoServerError): """Failed to retrieve AQL user functions."""
[docs]class AQLFunctionCreateError(ArangoServerError): """Failed to create AQL user function."""
[docs]class AQLFunctionDeleteError(ArangoServerError): """Failed to delete AQL user function."""
############################## # Async Execution Exceptions # ##############################
[docs]class AsyncExecuteError(ArangoServerError): """Failed to execute async API request."""
[docs]class AsyncJobListError(ArangoServerError): """Failed to retrieve async jobs."""
[docs]class AsyncJobCancelError(ArangoServerError): """Failed to cancel async job."""
[docs]class AsyncJobStatusError(ArangoServerError): """Failed to retrieve async job status."""
[docs]class AsyncJobResultError(ArangoServerError): """Failed to retrieve async job result."""
[docs]class AsyncJobClearError(ArangoServerError): """Failed to clear async job results."""
############################## # Backup Exceptions # ##############################
[docs]class BackupCreateError(ArangoServerError): """Failed to create a backup."""
[docs]class BackupDeleteError(ArangoServerError): """Failed to delete a backup."""
[docs]class BackupDownloadError(ArangoServerError): """Failed to download a backup from remote repository."""
[docs]class BackupGetError(ArangoServerError): """Failed to retrieve backup details."""
[docs]class BackupRestoreError(ArangoServerError): """Failed to restore from backup."""
[docs]class BackupUploadError(ArangoServerError): """Failed to upload a backup to remote repository."""
############################## # Batch Execution Exceptions # ##############################
[docs]class BatchStateError(ArangoClientError): """The batch object was in a bad state."""
[docs]class BatchJobResultError(ArangoClientError): """Failed to retrieve batch job result."""
[docs]class BatchExecuteError(ArangoServerError): """Failed to execute batch API request."""
######################### # Collection Exceptions # #########################
[docs]class CollectionListError(ArangoServerError): """Failed to retrieve collections."""
[docs]class CollectionPropertiesError(ArangoServerError): """Failed to retrieve collection properties."""
[docs]class CollectionConfigureError(ArangoServerError): """Failed to configure collection properties."""
[docs]class CollectionStatisticsError(ArangoServerError): """Failed to retrieve collection statistics."""
[docs]class CollectionRevisionError(ArangoServerError): """Failed to retrieve collection revision."""
[docs]class CollectionChecksumError(ArangoServerError): """Failed to retrieve collection checksum."""
[docs]class CollectionCreateError(ArangoServerError): """Failed to create collection."""
[docs]class CollectionDeleteError(ArangoServerError): """Failed to delete collection."""
[docs]class CollectionRenameError(ArangoServerError): """Failed to rename collection."""
[docs]class CollectionTruncateError(ArangoServerError): """Failed to truncate collection."""
[docs]class CollectionLoadError(ArangoServerError): """Failed to load collection."""
[docs]class CollectionUnloadError(ArangoServerError): """Failed to unload collection."""
[docs]class CollectionRecalculateCountError(ArangoServerError): """Failed to recalculate document count."""
[docs]class CollectionResponsibleShardError(ArangoServerError): """Failed to retrieve responsible shard."""
##################### # Cursor Exceptions # #####################
[docs]class CursorStateError(ArangoClientError): """The cursor object was in a bad state."""
[docs]class CursorCountError(ArangoClientError, TypeError): """The cursor count was not enabled."""
[docs]class CursorEmptyError(ArangoClientError): """The current batch in cursor was empty."""
[docs]class CursorNextError(ArangoServerError): """Failed to retrieve the next result batch from server."""
[docs]class CursorCloseError(ArangoServerError): """Failed to delete the cursor result from server."""
####################### # Database Exceptions # #######################
[docs]class DatabaseListError(ArangoServerError): """Failed to retrieve databases."""
[docs]class DatabasePropertiesError(ArangoServerError): """Failed to retrieve database properties."""
[docs]class DatabaseCreateError(ArangoServerError): """Failed to create database."""
[docs]class DatabaseDeleteError(ArangoServerError): """Failed to delete database."""
####################### # Document Exceptions # #######################
[docs]class DocumentParseError(ArangoClientError): """Failed to parse document input."""
[docs]class DocumentCountError(ArangoServerError): """Failed to retrieve document count."""
[docs]class DocumentInError(ArangoServerError): """Failed to check whether document exists."""
[docs]class DocumentGetError(ArangoServerError): """Failed to retrieve document."""
[docs]class DocumentKeysError(ArangoServerError): """Failed to retrieve document keys."""
[docs]class DocumentIDsError(ArangoServerError): """Failed to retrieve document IDs."""
[docs]class DocumentInsertError(ArangoServerError): """Failed to insert document."""
[docs]class DocumentReplaceError(ArangoServerError): """Failed to replace document."""
[docs]class DocumentUpdateError(ArangoServerError): """Failed to update document."""
[docs]class DocumentDeleteError(ArangoServerError): """Failed to delete document."""
[docs]class DocumentRevisionError(ArangoServerError): """The expected and actual document revisions mismatched."""
################### # Foxx Exceptions # ###################
[docs]class FoxxServiceListError(ArangoServerError): """Failed to retrieve Foxx services."""
[docs]class FoxxServiceGetError(ArangoServerError): """Failed to retrieve Foxx service metadata."""
[docs]class FoxxServiceCreateError(ArangoServerError): """Failed to create Foxx service."""
[docs]class FoxxServiceUpdateError(ArangoServerError): """Failed to update Foxx service."""
[docs]class FoxxServiceReplaceError(ArangoServerError): """Failed to replace Foxx service."""
[docs]class FoxxServiceDeleteError(ArangoServerError): """Failed to delete Foxx services."""
[docs]class FoxxConfigGetError(ArangoServerError): """Failed to retrieve Foxx service configuration."""
[docs]class FoxxConfigUpdateError(ArangoServerError): """Failed to update Foxx service configuration."""
[docs]class FoxxConfigReplaceError(ArangoServerError): """Failed to replace Foxx service configuration."""
[docs]class FoxxDependencyGetError(ArangoServerError): """Failed to retrieve Foxx service dependencies."""
[docs]class FoxxDependencyUpdateError(ArangoServerError): """Failed to update Foxx service dependencies."""
[docs]class FoxxDependencyReplaceError(ArangoServerError): """Failed to replace Foxx service dependencies."""
[docs]class FoxxScriptListError(ArangoServerError): """Failed to retrieve Foxx service scripts."""
[docs]class FoxxScriptRunError(ArangoServerError): """Failed to run Foxx service script."""
[docs]class FoxxTestRunError(ArangoServerError): """Failed to run Foxx service tests."""
[docs]class FoxxDevModeEnableError(ArangoServerError): """Failed to enable development mode for Foxx service."""
[docs]class FoxxDevModeDisableError(ArangoServerError): """Failed to disable development mode for Foxx service."""
[docs]class FoxxReadmeGetError(ArangoServerError): """Failed to retrieve Foxx service readme."""
[docs]class FoxxSwaggerGetError(ArangoServerError): """Failed to retrieve Foxx service swagger."""
[docs]class FoxxDownloadError(ArangoServerError): """Failed to download Foxx service bundle."""
[docs]class FoxxCommitError(ArangoServerError): """Failed to commit local Foxx service state."""
#################### # Graph Exceptions # ####################
[docs]class GraphListError(ArangoServerError): """Failed to retrieve graphs."""
[docs]class GraphCreateError(ArangoServerError): """Failed to create the graph."""
[docs]class GraphDeleteError(ArangoServerError): """Failed to delete the graph."""
[docs]class GraphPropertiesError(ArangoServerError): """Failed to retrieve graph properties."""
[docs]class GraphTraverseError(ArangoServerError): """Failed to execute graph traversal."""
[docs]class VertexCollectionListError(ArangoServerError): """Failed to retrieve vertex collections."""
[docs]class VertexCollectionCreateError(ArangoServerError): """Failed to create vertex collection."""
[docs]class VertexCollectionDeleteError(ArangoServerError): """Failed to delete vertex collection."""
[docs]class EdgeDefinitionListError(ArangoServerError): """Failed to retrieve edge definitions."""
[docs]class EdgeDefinitionCreateError(ArangoServerError): """Failed to create edge definition."""
[docs]class EdgeDefinitionReplaceError(ArangoServerError): """Failed to replace edge definition."""
[docs]class EdgeDefinitionDeleteError(ArangoServerError): """Failed to delete edge definition."""
[docs]class EdgeListError(ArangoServerError): """Failed to retrieve edges coming in and out of a vertex."""
#################### # Index Exceptions # ####################
[docs]class IndexListError(ArangoServerError): """Failed to retrieve collection indexes."""
[docs]class IndexCreateError(ArangoServerError): """Failed to create collection index."""
[docs]class IndexDeleteError(ArangoServerError): """Failed to delete collection index."""
[docs]class IndexLoadError(ArangoServerError): """Failed to load indexes into memory."""
##################### # Pregel Exceptions # #####################
[docs]class PregelJobCreateError(ArangoServerError): """Failed to create Pregel job."""
[docs]class PregelJobGetError(ArangoServerError): """Failed to retrieve Pregel job details."""
[docs]class PregelJobDeleteError(ArangoServerError): """Failed to delete Pregel job."""
##################### # Server Exceptions # #####################
[docs]class ServerConnectionError(ArangoClientError): """Failed to connect to ArangoDB server."""
[docs]class ServerEngineError(ArangoServerError): """Failed to retrieve database engine."""
[docs]class ServerVersionError(ArangoServerError): """Failed to retrieve server version."""
[docs]class ServerDetailsError(ArangoServerError): """Failed to retrieve server details."""
[docs]class ServerStatusError(ArangoServerError): """Failed to retrieve server status."""
[docs]class ServerTimeError(ArangoServerError): """Failed to retrieve server system time."""
[docs]class ServerEchoError(ArangoServerError): """Failed to retrieve details on last request."""
[docs]class ServerShutdownError(ArangoServerError): """Failed to initiate shutdown sequence."""
[docs]class ServerRunTestsError(ArangoServerError): """Failed to execute server tests."""
[docs]class ServerRequiredDBVersionError(ArangoServerError): """Failed to retrieve server target version."""
[docs]class ServerReadLogError(ArangoServerError): """Failed to retrieve global log."""
[docs]class ServerLogLevelError(ArangoServerError): """Failed to retrieve server log levels."""
[docs]class ServerLogLevelSetError(ArangoServerError): """Failed to set server log levels."""
[docs]class ServerReloadRoutingError(ArangoServerError): """Failed to reload routing details."""
[docs]class ServerStatisticsError(ArangoServerError): """Failed to retrieve server statistics."""
[docs]class ServerMetricsError(ArangoServerError): """Failed to retrieve server metrics."""
[docs]class ServerRoleError(ArangoServerError): """Failed to retrieve server role in a cluster."""
[docs]class ServerTLSError(ArangoServerError): """Failed to retrieve TLS data."""
[docs]class ServerTLSReloadError(ArangoServerError): """Failed to reload TLS."""
[docs]class ServerEncryptionError(ArangoServerError): """Failed to reload user-defined encryption keys."""
##################### # Task Exceptions # #####################
[docs]class TaskListError(ArangoServerError): """Failed to retrieve server tasks."""
[docs]class TaskGetError(ArangoServerError): """Failed to retrieve server task details."""
[docs]class TaskCreateError(ArangoServerError): """Failed to create server task."""
[docs]class TaskDeleteError(ArangoServerError): """Failed to delete server task."""
########################## # Transaction Exceptions # ##########################
[docs]class TransactionExecuteError(ArangoServerError): """Failed to execute raw transaction."""
[docs]class TransactionInitError(ArangoServerError): """Failed to initialize transaction."""
[docs]class TransactionStatusError(ArangoServerError): """Failed to retrieve transaction status."""
[docs]class TransactionCommitError(ArangoServerError): """Failed to commit transaction."""
[docs]class TransactionAbortError(ArangoServerError): """Failed to abort transaction."""
################### # User Exceptions # ###################
[docs]class UserListError(ArangoServerError): """Failed to retrieve users."""
[docs]class UserGetError(ArangoServerError): """Failed to retrieve user details."""
[docs]class UserCreateError(ArangoServerError): """Failed to create user."""
[docs]class UserUpdateError(ArangoServerError): """Failed to update user."""
[docs]class UserReplaceError(ArangoServerError): """Failed to replace user."""
[docs]class UserDeleteError(ArangoServerError): """Failed to delete user."""
################### # View Exceptions # ###################
[docs]class ViewListError(ArangoServerError): """Failed to retrieve views."""
[docs]class ViewGetError(ArangoServerError): """Failed to retrieve view details."""
[docs]class ViewCreateError(ArangoServerError): """Failed to create view."""
[docs]class ViewUpdateError(ArangoServerError): """Failed to update view."""
[docs]class ViewReplaceError(ArangoServerError): """Failed to replace view."""
[docs]class ViewDeleteError(ArangoServerError): """Failed to delete view."""
[docs]class ViewRenameError(ArangoServerError): """Failed to rename view."""
####################### # Analyzer Exceptions # #######################
[docs]class AnalyzerListError(ArangoServerError): """Failed to retrieve analyzers."""
[docs]class AnalyzerGetError(ArangoServerError): """Failed to retrieve analyzer details."""
[docs]class AnalyzerCreateError(ArangoServerError): """Failed to create analyzer."""
[docs]class AnalyzerDeleteError(ArangoServerError): """Failed to delete analyzer."""
######################### # Permission Exceptions # #########################
[docs]class PermissionListError(ArangoServerError): """Failed to list user permissions."""
[docs]class PermissionGetError(ArangoServerError): """Failed to retrieve user permission."""
[docs]class PermissionUpdateError(ArangoServerError): """Failed to update user permission."""
[docs]class PermissionResetError(ArangoServerError): """Failed to reset user permission."""
################## # WAL Exceptions # ##################
[docs]class WALPropertiesError(ArangoServerError): """Failed to retrieve WAL properties."""
[docs]class WALConfigureError(ArangoServerError): """Failed to configure WAL properties."""
[docs]class WALTransactionListError(ArangoServerError): """Failed to retrieve running WAL transactions."""
[docs]class WALFlushError(ArangoServerError): """Failed to flush WAL."""
[docs]class WALTickRangesError(ArangoServerError): """Failed to return WAL tick ranges."""
[docs]class WALLastTickError(ArangoServerError): """Failed to return WAL tick ranges."""
[docs]class WALTailError(ArangoServerError): """Failed to return WAL tick ranges."""
########################## # Replication Exceptions # ##########################
[docs]class ReplicationInventoryError(ArangoServerError): """Failed to retrieve inventory of collection and indexes."""
[docs]class ReplicationDumpBatchCreateError(ArangoServerError): """Failed to create dump batch."""
[docs]class ReplicationDumpBatchDeleteError(ArangoServerError): """Failed to delete a dump batch."""
[docs]class ReplicationDumpBatchExtendError(ArangoServerError): """Failed to extend a dump batch."""
[docs]class ReplicationDumpError(ArangoServerError): """Failed to retrieve collection content."""
[docs]class ReplicationSyncError(ArangoServerError): """Failed to synchronize data from remote."""
[docs]class ReplicationClusterInventoryError(ArangoServerError): """Failed to retrieve overview of collection and indexes in a cluster."""
[docs]class ReplicationLoggerStateError(ArangoServerError): """Failed to retrieve logger state."""
[docs]class ReplicationLoggerFirstTickError(ArangoServerError): """Failed to retrieve logger first tick."""
[docs]class ReplicationApplierConfigError(ArangoServerError): """Failed to retrieve replication applier configuration."""
[docs]class ReplicationApplierConfigSetError(ArangoServerError): """Failed to update replication applier configuration."""
[docs]class ReplicationApplierStartError(ArangoServerError): """Failed to start replication applier."""
[docs]class ReplicationApplierStopError(ArangoServerError): """Failed to stop replication applier."""
[docs]class ReplicationApplierStateError(ArangoServerError): """Failed to retrieve replication applier state."""
[docs]class ReplicationMakeSlaveError(ArangoServerError): """Failed to change role to slave."""
[docs]class ReplicationServerIDError(ArangoServerError): """Failed to retrieve server ID."""
###################### # Cluster Exceptions # ######################
[docs]class ClusterHealthError(ArangoServerError): """Failed to retrieve DBServer health."""
[docs]class ClusterServerIDError(ArangoServerError): """Failed to retrieve server ID."""
[docs]class ClusterServerRoleError(ArangoServerError): """Failed to retrieve server role."""
[docs]class ClusterServerStatisticsError(ArangoServerError): """Failed to retrieve DBServer statistics."""
[docs]class ClusterServerVersionError(ArangoServerError): """Failed to retrieve server node version."""
[docs]class ClusterServerEngineError(ArangoServerError): """Failed to retrieve server node engine."""
[docs]class ClusterMaintenanceModeError(ArangoServerError): """Failed to enable/disable cluster supervision maintenance mode."""
[docs]class ClusterEndpointsError(ArangoServerError): """Failed to retrieve cluster endpoints."""
[docs]class ClusterServerCountError(ArangoServerError): """Failed to retrieve cluster server count."""
################## # JWT Exceptions # ##################
[docs]class JWTAuthError(ArangoServerError): """Failed to get a new JWT token from ArangoDB."""
[docs]class JWTSecretListError(ArangoServerError): """Failed to retrieve information on currently loaded JWT secrets."""
[docs]class JWTSecretReloadError(ArangoServerError): """Failed to reload JWT secrets."""