2019-04-06 12:26:42 +00:00
|
|
|
class AnticaptchaException(Exception):
|
|
|
|
def __init__(self, error_id, error_code, error_description, *args):
|
2022-01-24 04:07:52 +00:00
|
|
|
super(AnticaptchaException, self).__init__(
|
|
|
|
"[{}:{}]{}".format(error_code, error_id, error_description)
|
|
|
|
)
|
2019-04-06 12:26:42 +00:00
|
|
|
self.error_description = error_description
|
|
|
|
self.error_id = error_id
|
|
|
|
self.error_code = error_code
|
|
|
|
|
|
|
|
|
|
|
|
AnticatpchaException = AnticaptchaException
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidWidthException(AnticaptchaException):
|
|
|
|
def __init__(self, width):
|
|
|
|
self.width = width
|
2022-01-24 04:07:52 +00:00
|
|
|
msg = "Invalid width (%s). Can be one of these: 100, 50, 33, 25." % (
|
|
|
|
self.width,
|
|
|
|
)
|
2019-04-06 12:26:42 +00:00
|
|
|
super(InvalidWidthException, self).__init__("AC-1", 1, msg)
|
|
|
|
|
|
|
|
|
|
|
|
class MissingNameException(AnticaptchaException):
|
|
|
|
def __init__(self, cls):
|
|
|
|
self.cls = cls
|
2022-01-24 04:07:52 +00:00
|
|
|
msg = 'Missing name data in {0}. Provide {0}.__init__(name="X") or {0}.serialize(name="X")'.format(
|
|
|
|
str(self.cls)
|
|
|
|
)
|
2019-04-06 12:26:42 +00:00
|
|
|
super(MissingNameException, self).__init__("AC-2", 2, msg)
|