File size: 1,343 Bytes
3e848bc
 
 
 
 
 
 
 
65c7dd4
3e848bc
 
 
 
 
 
 
 
 
 
a06172d
3e848bc
 
f06c14e
a3c0252
f06c14e
 
a3c0252
 
f06c14e
 
82f3d24
 
 
 
 
 
 
f06c14e
a06172d
f06c14e
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

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)