Skip to content

base_service

Base service module

Classes

BaseService

BaseService(
    sa_session: SASession, neo4j_session: NJSession
)

Bases: ABC

Base service layer

Attributes

neo4j_session property
neo4j_session: NJSession
sa_session property
sa_session: SASession

Functions

ResponseCode

Bases: Enum

Service-layer response codes.

Attributes

FEATURE_NOT_SUPPORTED class-attribute instance-attribute
FEATURE_NOT_SUPPORTED = 1011
GENERAL_SERVICE_ERROR class-attribute instance-attribute
GENERAL_SERVICE_ERROR = 1000
INVALID_INPUT class-attribute instance-attribute
INVALID_INPUT = 1001
LLM_ERROR class-attribute instance-attribute
LLM_ERROR = 1009
RESOURCE_ALREADY_EXISTS class-attribute instance-attribute
RESOURCE_ALREADY_EXISTS = 1004
RESOURCE_DELETED class-attribute instance-attribute
RESOURCE_DELETED = 1005
RESOURCE_DISABLED class-attribute instance-attribute
RESOURCE_DISABLED = 1006
RESOURCE_INVALID_OWNERSHIP class-attribute instance-attribute
RESOURCE_INVALID_OWNERSHIP = 1007
RESOURCE_INVALID_STATE class-attribute instance-attribute
RESOURCE_INVALID_STATE = 1002
RESOURCE_NOT_FOUND class-attribute instance-attribute
RESOURCE_NOT_FOUND = 1003
RESOURCE_READ_ONLY class-attribute instance-attribute
RESOURCE_READ_ONLY = 1008
SUCCESS class-attribute instance-attribute
SUCCESS = 0
SUCCESS_PARTIAL class-attribute instance-attribute
SUCCESS_PARTIAL = 1010

ServiceError

ServiceError(
    msg: Optional[str] = None,
    code: ResponseCode = GENERAL_SERVICE_ERROR,
    trace_id: Optional[str] = None,
)

Bases: Exception

Custom exception class for service execution errors.

ServiceError is used throughout the service layer to standardize error handling and reporting. It provides structured information about the error, including a numeric error code, a human-readable description, and a unique trace identifier for better error tracking and client support. Moreover this mechanism prevents the need to pass raw exception details back to the client, which could expose sensitive information or unwanted implementation details.

Attributes

code instance-attribute
code = code
error_code instance-attribute
error_code = value
error_message instance-attribute
error_message = f'{error_name}'
error_name instance-attribute
error_name = name
trace_id instance-attribute
trace_id = trace_id or gen_uuid(prefix='trace.')

Functions

__str__
__str__() -> str

Functions