Spaces:
Runtime error
Runtime error
from abc import abstractmethod | |
from typing import Dict, Type | |
from overrides import overrides, EnforceOverrides | |
class ChromaError(Exception, EnforceOverrides): | |
def code(self) -> int: | |
"""Return an appropriate HTTP response code for this error""" | |
return 400 # Bad Request | |
def message(self) -> str: | |
return ", ".join(self.args) | |
def name(self) -> str: | |
"""Return the error name""" | |
pass | |
class InvalidDimensionException(ChromaError): | |
def name(cls) -> str: | |
return "InvalidDimension" | |
class IDAlreadyExistsError(ChromaError): | |
def code(self) -> int: | |
return 409 # Conflict | |
def name(cls) -> str: | |
return "IDAlreadyExists" | |
class DuplicateIDError(ChromaError): | |
def name(cls) -> str: | |
return "DuplicateID" | |
class InvalidUUIDError(ChromaError): | |
def name(cls) -> str: | |
return "InvalidUUID" | |
error_types: Dict[str, Type[ChromaError]] = { | |
"InvalidDimension": InvalidDimensionException, | |
"IDAlreadyExists": IDAlreadyExistsError, | |
"DuplicateID": DuplicateIDError, | |
"InvalidUUID": InvalidUUIDError, | |
} | |