/
errors.rb
69 lines (57 loc) · 1.38 KB
/
errors.rb
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
module DeathByCaptcha
module Errors
#
# Custom Error class for rescuing from DeathByCaptcha API errors.
#
class Error < StandardError
def initialize(message)
super("#{message} (DEATHBYCAPTCHA API ERROR)")
end
end
#
# Raised when a method tries to access a not implemented method.
#
class NotImplemented < Error
def initialize
super('The requested functionality was not implemented')
end
end
#
# Raised when a HTTP call fails.
#
class CallError < Error
def initialize
super('HTTP call failed')
end
end
#
# Raised when the user is not allowed to access the API.
#
class AccessDenied < Error
def initialize
super('Access denied, please check your credentials and/or balance')
end
end
#
# Raised when the captcha file could not be loaded or is empty.
#
class CaptchaEmpty < Error
def initialize
super('CAPTCHA image is empty or could not be loaded')
end
end
#
# Raised when the size of the captcha file is too big.
#
class CaptchaOverflow < Error
def initialize
super('CAPTCHA image is too big')
end
end
class ServiceOverload < Error
def initialize
super('CAPTCHA was rejected due to service overload, try again later')
end
end
end
end