File size: 1,769 Bytes
7a87926 |
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
"""
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."""
|