This repository was archived by the owner on Nov 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy patherrors.rb
121 lines (91 loc) · 3.08 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# Custom error class for rescuing DataSift errors
class DataSiftError < StandardError
attr_reader :status, :body, :response
def initialize(http_status = nil, http_body = nil, response_on_error = nil)
@status = http_status
@body = http_body
@response = response_on_error
end
def message
@body.nil? ? @status : @body
end
def to_s
# If both body and status were provided then message is the body otherwise
# the status contains the message
msg = [email protected]? && [email protected]? ? @body : @status
# If body is nil then status is the message body so no status is included
status_string = @body.nil? ? '' : "(Status #{@status}) "
"#{status_string} : #{msg}"
end
end
class NotSupportedError < DataSiftError
end
# Standard error returned when receiving a 400 response from the API
class BadRequestError < DataSiftError
end
# Standard error returned when receiving a 401 response from the API
class AuthError < DataSiftError
end
class ConnectionError < DataSiftError
end
# Standard error returned when receiving a 403 response from the API
class ForbiddenError < DataSiftError
end
# Standard error returned when receiving a 404 response from the API
class ApiResourceNotFoundError < DataSiftError
end
# Standard error returned when receiving a 405 response from the API
class MethodNotAllowedError < DataSiftError
end
# Standard error returned when receiving a 409 response from the API
class ConflictError < DataSiftError
end
# Standard error returned when receiving a 410 response from the API
class GoneError < DataSiftError
end
# Standard error returned when receiving a 412 response from the API
class PreconditionFailedError < DataSiftError
end
# Standard error returned when receiving a 413 response from the API
class PayloadTooLargeError < DataSiftError
end
# Standard error returned when receiving a 415 response from the API
class UnsupportedMediaTypeError < DataSiftError
end
# Standard error returned when receiving a 422 response from the API
class UnprocessableEntityError < DataSiftError
end
# Standard error returned when receiving a 429 response from the API
class TooManyRequestsError < DataSiftError
end
# Standard error returned when receiving a 500 response from the API
class InternalServerError < DataSiftError
end
# Standard error returned when receiving a 502 response from the API
class BadGatewayError < DataSiftError
end
# Standard error returned when receiving a 503 response from the API
class ServiceUnavailableError < DataSiftError
end
# Standard error returned when receiving a 504 response from the API
class GatewayTimeoutError < DataSiftError
end
class InvalidConfigError < DataSiftError
end
class InvalidParamError < DataSiftError
end
class NotConnectedError < DataSiftError
end
class ReconnectTimeoutError < DataSiftError
end
class NotConfiguredError < DataSiftError
end
class InvalidTypeError < DataSiftError
end
class StreamingMessageError < DataSiftError
end
class WebSocketOnWindowsError < DataSiftError
end
# Standard error returned when trying to use a method while missing parameters
class BadParametersError < DataSiftError
end