Exceptions¶
Exception classes for es_client
This module defines custom exceptions for es_client, used in
Builder, logging,
config, schemacheck, and
utils to handle specific error conditions.
- Classes:
ESClientException: Base class for non-Elasticsearch exceptions. ConfigurationError: Exception for misconfiguration issues. MissingArgument: Exception for missing required arguments. NotMaster: Exception for non-master node connections. LoggingException: Exception for logging configuration failures. SchemaException: Base class for schema-related exceptions. FailedValidation: Exception for SchemaCheck validation failures.
- es_client.exceptions.password_filter(data)[source]¶
Redact sensitive values from a configuration dictionary.
- Parameters:
data (dict) – Configuration dictionary to process.
- Returns:
- A deep copy of data with sensitive values (keys in
KEYS_TO_REDACT) replaced with ‘REDACTED’.
- Return type:
Recursively traverses data, replacing values of keys listed in
KEYS_TO_REDACT(e.g., ‘password’, ‘api_key’) with ‘REDACTED’ for secure logging.Example
>>> data = {'user': 'test', 'password': 'secret', 'nested': {'api_key': 'key'}} >>> filtered = password_filter(data) >>> filtered {'user': 'test', 'password': 'REDACTED', 'nested': {'api_key': 'REDACTED'}} >>> data['password'] # Original unchanged 'secret'
- exception es_client.exceptions.ESClientException[source]¶
Bases:
ExceptionBase class for non-Elasticsearch exceptions in es_client.
Example
>>> raise ESClientException('Generic error') Traceback (most recent call last): ... es_client.exceptions.ESClientException: Generic error
- exception es_client.exceptions.ConfigurationError[source]¶
Bases:
ESClientExceptionException for configuration errors in es_client.
Raised when invalid settings are detected, such as malformed hosts or YAML files.
Example
>>> raise ConfigurationError('Invalid host schema') Traceback (most recent call last): ... es_client.exceptions.ConfigurationError: Invalid host schema
- exception es_client.exceptions.MissingArgument[source]¶
Bases:
ESClientExceptionException for missing required arguments in es_client.
Raised when a necessary parameter is not provided.
Example
>>> raise MissingArgument('Missing username') Traceback (most recent call last): ... es_client.exceptions.MissingArgument: Missing username
- exception es_client.exceptions.NotMaster[source]¶
Bases:
ESClientExceptionException for non-master node connections in es_client.
Raised when a node is not the elected master and master_only is True.
Example
>>> raise NotMaster('Not the master node') Traceback (most recent call last): ... es_client.exceptions.NotMaster: Not the master node
- exception es_client.exceptions.LoggingException[source]¶
Bases:
ESClientExceptionException for logging configuration failures in es_client.
Raised when logging cannot be configured properly.
Example
>>> raise LoggingException('Logging setup failed') Traceback (most recent call last): ... es_client.exceptions.LoggingException: Logging setup failed
- exception es_client.exceptions.SchemaException[source]¶
Bases:
ESClientExceptionBase class for schema-related exceptions in es_client.
Example
>>> raise SchemaException('Schema error') Traceback (most recent call last): ... es_client.exceptions.SchemaException: Schema error
- exception es_client.exceptions.FailedValidation[source]¶
Bases:
SchemaExceptionException for SchemaCheck validation failures in es_client.
Raised when
SchemaCheckvalidation fails.Example
>>> raise FailedValidation('Invalid value detected') Traceback (most recent call last): ... es_client.exceptions.FailedValidation: Invalid value detected