- Introduction of API-functionality (to be continued). Deduplication of document and url uploads between views and api. - Improvements on document processing - introduction of processor classes to streamline document inputs - Removed pure Youtube functionality, as Youtube retrieval of documents continuously changes. But added upload of srt, mp3, ogg and mp4
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
class EveAIException(Exception):
|
|
"""Base exception class for EveAI API"""
|
|
|
|
def __init__(self, message, status_code=400, payload=None):
|
|
super().__init__()
|
|
self.message = message
|
|
self.status_code = status_code
|
|
self.payload = payload
|
|
|
|
def to_dict(self):
|
|
rv = dict(self.payload or ())
|
|
rv['message'] = self.message
|
|
return rv
|
|
|
|
|
|
class EveAIInvalidLanguageException(EveAIException):
|
|
"""Raised when an invalid language is provided"""
|
|
|
|
def __init__(self, message="Langage is required", status_code=400, payload=None):
|
|
super().__init__(message, status_code, payload)
|
|
|
|
|
|
class EveAIDoubleURLException(EveAIException):
|
|
"""Raised when an existing url is provided"""
|
|
|
|
def __init__(self, message="URL already exists", status_code=400, payload=None):
|
|
super().__init__(message, status_code, payload)
|
|
|
|
|
|
class EveAIUnsupportedFileType(EveAIException):
|
|
"""Raised when an invalid file type is provided"""
|
|
|
|
def __init__(self, message="Filetype is not supported", status_code=400, payload=None):
|
|
super().__init__(message, status_code, payload)
|
|
|
|
|
|
class EveAIYoutubeError(EveAIException):
|
|
"""Raised when adding a Youtube document fails"""
|
|
|
|
def __init__(self, message="Youtube document creation failed", status_code=400, payload=None):
|
|
super().__init__(message, status_code, payload)
|
|
|
|
# Add more custom exceptions as needed
|