Skip to content

Logging Service Errors

consortium.server.exceptions.service_exceptions.logging_service_exceptions

Exception hierarchy:

LoggingServiceError(message='', detail=None)

Bases: BaseServiceError

Base exception for all errors that occur within the logging service.

Attributes:

Name Type Description
code

A stable machine-readable string identifying the specific error.

message str

A human-readable description of what went wrong and, where possible, how to resolve it.

detail dict[str, JsonValue] | None

Optional structured context about the error, or None when there is none.

code = 'LOGGING_SERVICE_ERROR' class-attribute instance-attribute

SinkNotFoundError(operation, label)

Bases: LoggingServiceError

Raised when the requested log sink was not found in the logging service.

code = 'SINK_NOT_FOUND_ERROR' class-attribute instance-attribute

SinkLabelAlreadyExistsError(label)

Bases: LoggingServiceError

Raised when attempting to add a log sink with a label that is already in use by another registered sink.

code = 'SINK_LABEL_ALREADY_EXISTS_ERROR' class-attribute instance-attribute

SinkConfigurationError(operation, label, underlying_error)

Bases: LoggingServiceError

Raised when loguru's logger.add rejects a sink's configuration.

Wraps the ValueError or TypeError loguru itself raises when the level, filter, or format string is invalid, or when sink or one of the forwarded keyword arguments is of an unexpected type. This does not cover the sink being an unopenable file path, which is reported separately through SinkFileSystemError.

code = 'SINK_CONFIGURATION_ERROR' class-attribute instance-attribute

SinkFileSystemError(operation, path, underlying_error)

Bases: LoggingServiceError

Raised when a log sink that is a file path cannot be opened by loguru.

This covers every way the filesystem can refuse to open the sink file: the containing directory does not exist, the process lacks the required permissions, the configured path points at a directory, the disk is full. They share one type because no caller can act differently on any of them: whatever the cause, the sink could not be opened, and the specific cause is carried in message and detail for whoever has to fix it.

code = 'SINK_FILE_SYSTEM_ERROR' class-attribute instance-attribute

StaleSinkHandlerError(operation, label, handler_id, underlying_error)

Bases: LoggingServiceError

Raised when loguru's logger.remove rejects a handler ID that this service still has registered for a sink.

This indicates something removed the handler behind this service's back: either logger.remove() was called directly on loguru, bypassing this service, or a second LoggingService was constructed, since LoggingService.__init__ itself calls logger.remove(), which invalidates every handler ID held by any earlier instance.

code = 'STALE_SINK_HANDLER_ERROR' class-attribute instance-attribute