sirus / backend /ml_module /core /exceptions.py
ranilmukesh's picture
Deploy SiRUS SQL Agent backend
783a952
# ml_module/core/exceptions.py
class MLEngineException(Exception):
"""Base exception for all custom errors in this module."""
def __init__(self, message: str):
self.message = message
super().__init__(self.message)
class ProjectNotFoundException(MLEngineException):
"""Raised when an operation is attempted on a non-existent project."""
def __init__(self, project_id: str):
super().__init__(f"Project with ID '{project_id}' not found.")
class StorageException(MLEngineException):
"""Raised for errors related to the storage service (e.g., MinIO connection)."""
def __init__(self, original_error: Exception):
super().__init__(f"An error occurred in the storage service: {original_error}")
class FileOperationException(StorageException):
"""Raised for errors during file read/write operations within storage."""
def __init__(self, operation: str, path: str, error: Exception):
super().__init__(f"Failed to {operation} file at '{path}': {error}")
# Phase 5: Sandbox Security and Execution Exceptions
class SandboxExecutionException(MLEngineException):
"""Raised when code execution in sandbox fails."""
def __init__(self, message: str, error_type: str = "execution_error"):
self.error_type = error_type
super().__init__(f"Sandbox execution failed: {message}")
class SecurityViolationException(MLEngineException):
"""Raised when code contains security violations."""
def __init__(self, message: str, violation_type: str = "security_violation"):
self.violation_type = violation_type
super().__init__(f"Security violation detected: {message}")