Spaces:
Running
Running
File size: 1,665 Bytes
783a952 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | # 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}") |