|
|
|
class BaseError(Exception): |
|
def __init__(self, val, message): |
|
self.val = val |
|
self.message = message |
|
super().__init__() |
|
|
|
def __str__(self): |
|
return "{} --> {}".format(self.val, self.message) |
|
|
|
|
|
class LanguageNotSupportedException(BaseError): |
|
def __init__(self, val, message="There is no support for the chosen language"): |
|
super().__init__(val, message) |
|
|
|
|
|
class NotValidPayload(BaseError): |
|
def __init__(self, |
|
val, |
|
message='text must be a valid text with maximum 5000 character, otherwise it cannot be translated'): |
|
super(NotValidPayload, self).__init__(val, message) |
|
|
|
|
|
class TranslationNotFound(BaseError): |
|
def __init__(self, |
|
val, |
|
message='No translation was found using the current translator. Try another translator?'): |
|
super(TranslationNotFound, self).__init__(val, message) |
|
|
|
|
|
class ElementNotFoundInGetRequest(BaseError): |
|
def __init__(self, |
|
val, |
|
message='Required element was not found in the API response'): |
|
super(ElementNotFoundInGetRequest, self).__init__(val, message) |
|
|
|
|
|
class NotValidLength(BaseError): |
|
def __init__(self, val, message="Length of text need to be between 0 and 5000"): |
|
super(NotValidLength, self).__init__(val, message) |
|
|