/
errors.rb
71 lines (55 loc) · 1.59 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
# frozen_string_literal: true
module Castle
# general error
class Error < RuntimeError
end
# Raised when anything is wrong with the request (any unhappy path)
# This error indicates that either we would wait too long for a response or something
# else happened somewhere in the middle and we weren't able to get the results
class RequestError < Castle::Error
attr_reader :reason
# @param reason [Exception] the core exception that causes this error
def initialize(reason)
@reason = reason
end
end
# security error
class SecurityError < Castle::Error
end
# wrong configuration error
class ConfigurationError < Castle::Error
end
# error returned by api
class ApiError < Castle::Error
end
# webhook signature verification error
class WebhookVerificationError < Castle::Error
end
# api error bad request 400
class BadRequestError < Castle::ApiError
end
# api error forbidden 403
class ForbiddenError < Castle::ApiError
end
# api error not found 404
class NotFoundError < Castle::ApiError
end
# api error user unauthorized 419
class UserUnauthorizedError < Castle::ApiError
end
# api error invalid param 422
class InvalidParametersError < Castle::ApiError
end
# api error invalid param 422 (invalid token)
class InvalidRequestTokenError < Castle::ApiError
end
# api error unauthorized 401
class UnauthorizedError < Castle::ApiError
end
# all internal server errors
class InternalServerError < Castle::ApiError
end
# impersonation command failed
class ImpersonationFailed < Castle::ApiError
end
end