3d_model / ylff /utils /exceptions.py
Azan
Clean deployment build (Squashed)
7a87926
"""
Custom exception classes for YLFF with user-friendly error messages.
"""
from typing import Any, Dict, Optional
class YLFFError(Exception):
"""Base exception for all YLFF errors."""
def __init__(
self,
message: str,
details: Optional[Dict[str, Any]] = None,
suggestion: Optional[str] = None,
):
"""
Args:
message: Human-readable error message
details: Additional error details (e.g., file paths, parameters)
suggestion: Helpful suggestion for resolving the error
"""
self.message = message
self.details = details or {}
self.suggestion = suggestion
super().__init__(self.message)
def to_dict(self) -> Dict[str, Any]:
"""Convert exception to dictionary for API responses."""
result = {
"error": self.__class__.__name__,
"message": self.message,
}
if self.details:
result["details"] = self.details
if self.suggestion:
result["suggestion"] = self.suggestion
return result
class ValidationError(YLFFError):
"""Error during validation process."""
class ModelLoadError(YLFFError):
"""Error loading or initializing ML model."""
class ConfigurationError(YLFFError):
"""Error in configuration or settings."""
class DataError(YLFFError):
"""Error with input data (missing files, invalid format, etc.)."""
class ProcessingError(YLFFError):
"""Error during data processing or computation."""
class JobError(YLFFError):
"""Error with job execution or status."""
class ARKitError(YLFFError):
"""Error processing ARKit data."""
class BAError(YLFFError):
"""Error during Bundle Adjustment."""