patient_http 1.6.1 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ARCHITECTURE.md +18 -8
- data/CHANGELOG.md +43 -0
- data/README.md +564 -508
- data/VERSION +1 -1
- data/lib/patient_http/callback_args.rb +53 -48
- data/lib/patient_http/callback_validator.rb +11 -7
- data/lib/patient_http/class_helper.rb +6 -7
- data/lib/patient_http/client.rb +53 -26
- data/lib/patient_http/client_pool.rb +134 -39
- data/lib/patient_http/completion_executor.rb +20 -20
- data/lib/patient_http/configuration.rb +405 -119
- data/lib/patient_http/connection_endpoint.rb +150 -0
- data/lib/patient_http/encryptor.rb +28 -18
- data/lib/patient_http/error.rb +24 -18
- data/lib/patient_http/external_storage.rb +42 -38
- data/lib/patient_http/http_error.rb +30 -26
- data/lib/patient_http/http_headers.rb +35 -29
- data/lib/patient_http/immediate_retries.rb +98 -0
- data/lib/patient_http/inline_task_handler.rb +15 -10
- data/lib/patient_http/lifecycle_manager.rb +39 -40
- data/lib/patient_http/outgoing_request.rb +25 -23
- data/lib/patient_http/payload.rb +28 -26
- data/lib/patient_http/payload_store/active_record_store.rb +31 -34
- data/lib/patient_http/payload_store/base.rb +42 -46
- data/lib/patient_http/payload_store/file_store.rb +22 -26
- data/lib/patient_http/payload_store/redis_store.rb +28 -34
- data/lib/patient_http/payload_store/s3_store.rb +25 -28
- data/lib/patient_http/payload_store.rb +2 -0
- data/lib/patient_http/processor.rb +111 -79
- data/lib/patient_http/processor_observer.rb +65 -59
- data/lib/patient_http/rails/engine.rb +13 -8
- data/lib/patient_http/redirect_error.rb +50 -41
- data/lib/patient_http/redirect_helper.rb +38 -38
- data/lib/patient_http/request.rb +117 -46
- data/lib/patient_http/request_error.rb +47 -42
- data/lib/patient_http/request_helper.rb +178 -119
- data/lib/patient_http/request_preparer.rb +13 -10
- data/lib/patient_http/request_task.rb +115 -84
- data/lib/patient_http/request_template.rb +119 -64
- data/lib/patient_http/response.rb +58 -52
- data/lib/patient_http/response_reader.rb +166 -118
- data/lib/patient_http/secret_manager.rb +34 -30
- data/lib/patient_http/secret_reference.rb +33 -26
- data/lib/patient_http/synchronous_executor.rb +84 -95
- data/lib/patient_http/task_handler.rb +23 -19
- data/lib/patient_http/time_helper.rb +8 -8
- data/lib/patient_http.rb +327 -186
- data/patient_http.gemspec +3 -2
- metadata +21 -5
data/lib/patient_http/request.rb
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module PatientHttp
|
|
4
|
-
#
|
|
4
|
+
# An HTTP request that a processor runs asynchronously.
|
|
5
5
|
#
|
|
6
|
-
# @example
|
|
6
|
+
# @example Create a GET request
|
|
7
7
|
# request = PatientHttp::Request.new(:get, "https://api.example.com/users/123")
|
|
8
8
|
#
|
|
9
|
-
# @example
|
|
9
|
+
# @example Create a POST request with a JSON body
|
|
10
10
|
# request = PatientHttp::Request.new(
|
|
11
11
|
# :post,
|
|
12
12
|
# "https://api.example.com/users",
|
|
@@ -16,53 +16,71 @@ module PatientHttp
|
|
|
16
16
|
UNDEFINED = Object.new.freeze
|
|
17
17
|
private_constant :UNDEFINED
|
|
18
18
|
|
|
19
|
-
#
|
|
19
|
+
# The supported HTTP methods.
|
|
20
20
|
VALID_METHODS = %i[get head post put patch delete query].freeze
|
|
21
21
|
|
|
22
|
-
# HTTP methods that
|
|
22
|
+
# The HTTP methods that can't have a request body.
|
|
23
23
|
BODYLESS_METHODS = %i[get head delete].freeze
|
|
24
24
|
|
|
25
|
-
#
|
|
25
|
+
# The HTTP methods that can be sent again without changing the result. As in
|
|
26
|
+
# RFC 9110, POST and PATCH aren't included.
|
|
27
|
+
IDEMPOTENT_METHODS = [:get, :head, :put, :delete, :query].freeze
|
|
28
|
+
|
|
29
|
+
# @return [Symbol] The HTTP method: `:get`, `:head`, `:post`, `:put`, `:patch`,
|
|
30
|
+
# `:delete`, or `:query`.
|
|
26
31
|
attr_reader :http_method
|
|
27
32
|
|
|
28
|
-
# @return [String] The request URL
|
|
33
|
+
# @return [String] The request URL.
|
|
29
34
|
attr_reader :url
|
|
30
35
|
|
|
31
|
-
# @return [HttpHeaders]
|
|
36
|
+
# @return [HttpHeaders] The request headers.
|
|
32
37
|
attr_reader :headers
|
|
33
38
|
|
|
34
|
-
# @return [Numeric, nil]
|
|
39
|
+
# @return [Numeric, nil] The timeout in seconds for the full request.
|
|
35
40
|
attr_reader :timeout
|
|
36
41
|
|
|
37
|
-
# @return [
|
|
42
|
+
# @return [Numeric, nil] The maximum number of seconds to wait for data from
|
|
43
|
+
# the server. The timer covers the wait for the response headers and
|
|
44
|
+
# starts again each time a body chunk arrives. If `nil`, the configuration
|
|
45
|
+
# value applies.
|
|
46
|
+
attr_reader :read_timeout
|
|
47
|
+
|
|
48
|
+
# @return [Integer, nil] The maximum response body size in bytes for this
|
|
49
|
+
# request. If `nil`, the configuration value applies.
|
|
50
|
+
attr_reader :max_response_size
|
|
51
|
+
|
|
52
|
+
# @return [Integer, nil] The maximum number of redirects to follow. If `0`,
|
|
53
|
+
# redirects aren't followed. If `nil`, the configuration value applies.
|
|
38
54
|
attr_reader :max_redirects
|
|
39
55
|
|
|
40
|
-
# @return [Boolean, nil] Whether a redirect that
|
|
41
|
-
#
|
|
56
|
+
# @return [Boolean, nil] Whether to follow a redirect that changes the HTTP
|
|
57
|
+
# method, such as POST to GET on a 302. If `nil`, the configuration value
|
|
58
|
+
# applies.
|
|
42
59
|
attr_reader :follow_method_changing_redirects
|
|
43
60
|
|
|
44
|
-
# @return [Array<String>]
|
|
45
|
-
# in addition to
|
|
61
|
+
# @return [Array<String>] The lowercase names of headers to remove from
|
|
62
|
+
# redirected requests, in addition to the names set in the {Configuration}.
|
|
46
63
|
attr_reader :redirect_strip_headers
|
|
47
64
|
|
|
48
|
-
# @return [Hash{String, Symbol => SecretReference}]
|
|
49
|
-
# secret references
|
|
65
|
+
# @return [Hash{String, Symbol => SecretReference}] The query parameters whose
|
|
66
|
+
# values are secret references. They aren't in the serialized URL. The
|
|
67
|
+
# processor resolves them when it sends the request.
|
|
50
68
|
attr_reader :secret_params
|
|
51
69
|
|
|
52
|
-
# @return [Array<String>]
|
|
53
|
-
#
|
|
70
|
+
# @return [Array<String>] The names of the registered preprocessors that run
|
|
71
|
+
# on the request before it's sent.
|
|
54
72
|
attr_reader :preprocessors
|
|
55
73
|
|
|
56
|
-
# @return [String, nil]
|
|
57
|
-
# Integrations use this to
|
|
58
|
-
#
|
|
74
|
+
# @return [String, nil] The name of the processor that runs the request.
|
|
75
|
+
# Integrations use this value to send the request to a named processor. If
|
|
76
|
+
# `nil`, the default processor runs the request.
|
|
59
77
|
attr_reader :processor
|
|
60
78
|
|
|
61
79
|
class << self
|
|
62
|
-
#
|
|
80
|
+
# Creates a request from its serialized form.
|
|
63
81
|
#
|
|
64
|
-
# @param hash [Hash] hash
|
|
65
|
-
# @return [Request]
|
|
82
|
+
# @param hash [Hash] The hash from {#as_json}.
|
|
83
|
+
# @return [Request] The request.
|
|
66
84
|
def load(hash)
|
|
67
85
|
new(
|
|
68
86
|
hash["http_method"].to_sym,
|
|
@@ -71,6 +89,8 @@ module PatientHttp
|
|
|
71
89
|
body: Payload.load(hash["body"])&.value,
|
|
72
90
|
params: load_secret_params(hash["secret_params"]),
|
|
73
91
|
timeout: hash["timeout"],
|
|
92
|
+
read_timeout: hash["read_timeout"],
|
|
93
|
+
max_response_size: hash["max_response_size"],
|
|
74
94
|
max_redirects: hash["max_redirects"],
|
|
75
95
|
follow_method_changing_redirects: hash["follow_method_changing_redirects"],
|
|
76
96
|
redirect_strip_headers: hash["redirect_strip_headers"],
|
|
@@ -98,26 +118,42 @@ module PatientHttp
|
|
|
98
118
|
end
|
|
99
119
|
end
|
|
100
120
|
|
|
101
|
-
#
|
|
121
|
+
# Creates a request.
|
|
102
122
|
#
|
|
103
|
-
# @param http_method [Symbol, String] HTTP method
|
|
123
|
+
# @param http_method [Symbol, String] The HTTP method: `:get`, `:head`, `:post`,
|
|
124
|
+
# `:put`, `:patch`, `:delete`, or `:query`.
|
|
104
125
|
# @param url [String, URI::Generic] The request URL.
|
|
105
|
-
# @param headers [Hash, HttpHeaders]
|
|
106
|
-
# @param body [String, nil]
|
|
107
|
-
#
|
|
108
|
-
# @param
|
|
109
|
-
#
|
|
110
|
-
# @param
|
|
111
|
-
# @param
|
|
112
|
-
#
|
|
113
|
-
#
|
|
114
|
-
#
|
|
115
|
-
#
|
|
116
|
-
#
|
|
117
|
-
# @param
|
|
118
|
-
#
|
|
119
|
-
#
|
|
120
|
-
#
|
|
126
|
+
# @param headers [Hash, HttpHeaders] The request headers.
|
|
127
|
+
# @param body [String, nil] The request body. GET, HEAD, and DELETE requests
|
|
128
|
+
# can't have a body.
|
|
129
|
+
# @param json [Object, nil] An object to send as a JSON body. Can't be combined
|
|
130
|
+
# with `body`.
|
|
131
|
+
# @param params [Hash, nil] The query parameters to add to the URL.
|
|
132
|
+
# @param timeout [Numeric, nil] The timeout in seconds for the full request.
|
|
133
|
+
# @param read_timeout [Numeric, nil] The maximum number of seconds to wait
|
|
134
|
+
# for data from the server. The timer covers the wait for the response
|
|
135
|
+
# headers and starts again each time a body chunk arrives. Use it for
|
|
136
|
+
# streamed responses. Do not use it when the server does all of its work
|
|
137
|
+
# before it sends the headers. If `nil`, the configuration value applies.
|
|
138
|
+
# @param max_response_size [Integer, nil] The maximum response body size in
|
|
139
|
+
# bytes. For a compressed response, the limit also applies to the
|
|
140
|
+
# decompressed body. If `nil`, the configuration value applies.
|
|
141
|
+
# @param max_redirects [Integer, nil] The maximum number of redirects to
|
|
142
|
+
# follow. If `0`, redirects aren't followed. If `nil`, the configuration
|
|
143
|
+
# value applies.
|
|
144
|
+
# @param follow_method_changing_redirects [Boolean, nil] Whether to follow a
|
|
145
|
+
# redirect that changes the HTTP method. If `false`, the redirect response is
|
|
146
|
+
# the result. If `nil`, the configuration value applies.
|
|
147
|
+
# @param redirect_strip_headers [String, Array<String>, nil] The names of headers
|
|
148
|
+
# to remove from redirected requests, in addition to the names set in the
|
|
149
|
+
# {Configuration}. Names are case insensitive.
|
|
150
|
+
# @param preprocessors [String, Symbol, Array<String, Symbol>, nil] The names of
|
|
151
|
+
# the registered preprocessors that run on the request before it's sent.
|
|
152
|
+
# @param processor [String, Symbol, nil] The name of the processor that runs
|
|
153
|
+
# the request. Integrations use this value to send the request to a named
|
|
154
|
+
# processor.
|
|
155
|
+
# @raise [ArgumentError] If the HTTP method, URL, body, `read_timeout`, or
|
|
156
|
+
# `max_response_size` isn't valid, or if both `body` and `json` are given.
|
|
121
157
|
def initialize(
|
|
122
158
|
http_method,
|
|
123
159
|
url,
|
|
@@ -126,6 +162,8 @@ module PatientHttp
|
|
|
126
162
|
json: nil,
|
|
127
163
|
params: nil,
|
|
128
164
|
timeout: nil,
|
|
165
|
+
read_timeout: nil,
|
|
166
|
+
max_response_size: nil,
|
|
129
167
|
max_redirects: nil,
|
|
130
168
|
follow_method_changing_redirects: nil,
|
|
131
169
|
redirect_strip_headers: nil,
|
|
@@ -145,6 +183,8 @@ module PatientHttp
|
|
|
145
183
|
@headers = headers.is_a?(HttpHeaders) ? headers.dup : HttpHeaders.new(headers)
|
|
146
184
|
@body = (body == "") ? nil : body
|
|
147
185
|
@timeout = timeout
|
|
186
|
+
@read_timeout = normalized_read_timeout(read_timeout)
|
|
187
|
+
@max_response_size = normalized_max_response_size(max_response_size)
|
|
148
188
|
@max_redirects = max_redirects
|
|
149
189
|
@follow_method_changing_redirects = normalized_follow_method_changing_redirects(follow_method_changing_redirects)
|
|
150
190
|
@redirect_strip_headers = RedirectHelper.normalize_header_names(redirect_strip_headers)
|
|
@@ -165,17 +205,25 @@ module PatientHttp
|
|
|
165
205
|
@body = UNDEFINED
|
|
166
206
|
end
|
|
167
207
|
|
|
168
|
-
# Returns the request body
|
|
208
|
+
# Returns the request body. The body is decoded on first access.
|
|
169
209
|
#
|
|
170
|
-
# @return [String, nil] The
|
|
210
|
+
# @return [String, nil] The request body, or `nil` if the request has no body.
|
|
171
211
|
def body
|
|
172
212
|
@body = @payload&.value if @body.equal?(UNDEFINED)
|
|
173
213
|
@body
|
|
174
214
|
end
|
|
175
215
|
|
|
176
|
-
#
|
|
216
|
+
# Returns whether the request can be sent again without changing the result.
|
|
217
|
+
# The HTTP method determines the value.
|
|
218
|
+
#
|
|
219
|
+
# @return [Boolean] `true` if the HTTP method is idempotent.
|
|
220
|
+
def idempotent?
|
|
221
|
+
IDEMPOTENT_METHODS.include?(@http_method)
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
# Returns the request as a JSON-compatible hash.
|
|
177
225
|
#
|
|
178
|
-
# @return [Hash]
|
|
226
|
+
# @return [Hash] The serialized request.
|
|
179
227
|
def as_json
|
|
180
228
|
hash = {
|
|
181
229
|
"http_method" => @http_method.to_s,
|
|
@@ -186,6 +234,9 @@ module PatientHttp
|
|
|
186
234
|
"max_redirects" => @max_redirects
|
|
187
235
|
}
|
|
188
236
|
|
|
237
|
+
hash["read_timeout"] = @read_timeout if @read_timeout
|
|
238
|
+
hash["max_response_size"] = @max_response_size if @max_response_size
|
|
239
|
+
|
|
189
240
|
if @secret_params.any?
|
|
190
241
|
hash["secret_params"] = @secret_params.transform_values(&:as_json)
|
|
191
242
|
end
|
|
@@ -219,6 +270,26 @@ module PatientHttp
|
|
|
219
270
|
raise ArgumentError.new("follow_method_changing_redirects must be true, false, or nil, got: #{value.inspect}")
|
|
220
271
|
end
|
|
221
272
|
|
|
273
|
+
# Validate the read timeout is a positive number or nil.
|
|
274
|
+
def normalized_read_timeout(value)
|
|
275
|
+
return nil if value.nil?
|
|
276
|
+
return value if value.is_a?(Numeric) && value > 0
|
|
277
|
+
|
|
278
|
+
raise ArgumentError.new(
|
|
279
|
+
"read_timeout must be a positive number or nil, got: #{value.inspect}"
|
|
280
|
+
)
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
# Validate the maximum response size is a positive integer or nil.
|
|
284
|
+
def normalized_max_response_size(value)
|
|
285
|
+
return nil if value.nil?
|
|
286
|
+
return value if value.is_a?(Integer) && value > 0
|
|
287
|
+
|
|
288
|
+
raise ArgumentError.new(
|
|
289
|
+
"max_response_size must be a positive integer or nil, got: #{value.inspect}"
|
|
290
|
+
)
|
|
291
|
+
end
|
|
292
|
+
|
|
222
293
|
# Normalize the processor name to a frozen string or nil.
|
|
223
294
|
def normalized_processor(processor)
|
|
224
295
|
return nil if processor.nil?
|
|
@@ -1,36 +1,37 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module PatientHttp
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
4
|
+
# The error for an exception that occurs while a request runs, such as a
|
|
5
|
+
# timeout, a connection failure, or an SSL error. HTTP error responses (4xx
|
|
6
|
+
# and 5xx) use {HttpError} instead.
|
|
7
7
|
#
|
|
8
|
-
#
|
|
8
|
+
# The error can be serialized, so a job system can pass it to the `on_error`
|
|
9
|
+
# callback in another process.
|
|
9
10
|
class RequestError < Error
|
|
10
|
-
#
|
|
11
|
+
# The valid error types.
|
|
11
12
|
ERROR_TYPES = [:timeout, :connection, :ssl, :response_too_large, :unknown].freeze
|
|
12
13
|
|
|
13
|
-
# @return [String]
|
|
14
|
+
# @return [String] The request URL.
|
|
14
15
|
attr_reader :url
|
|
15
16
|
|
|
16
|
-
# @return [Symbol] HTTP method
|
|
17
|
+
# @return [Symbol] The HTTP method.
|
|
17
18
|
attr_reader :http_method
|
|
18
19
|
|
|
19
|
-
# @return [Float]
|
|
20
|
+
# @return [Float] The request duration in seconds.
|
|
20
21
|
attr_reader :duration
|
|
21
22
|
|
|
22
|
-
# @return [String]
|
|
23
|
+
# @return [String] The unique request ID.
|
|
23
24
|
attr_reader :request_id
|
|
24
25
|
|
|
25
|
-
# @return [Symbol]
|
|
26
|
-
#
|
|
26
|
+
# @return [Symbol] The error category, one of {ERROR_TYPES}. For example,
|
|
27
|
+
# `:connection` includes I/O and socket errors.
|
|
27
28
|
attr_reader :error_type
|
|
28
29
|
|
|
29
30
|
class << self
|
|
30
|
-
#
|
|
31
|
+
# Creates an error from its serialized form.
|
|
31
32
|
#
|
|
32
|
-
# @param hash [Hash] hash
|
|
33
|
-
# @return [RequestError]
|
|
33
|
+
# @param hash [Hash] The hash from {#as_json}.
|
|
34
|
+
# @return [RequestError] The error.
|
|
34
35
|
def load(hash)
|
|
35
36
|
new(
|
|
36
37
|
class_name: hash["class_name"],
|
|
@@ -45,15 +46,15 @@ module PatientHttp
|
|
|
45
46
|
)
|
|
46
47
|
end
|
|
47
48
|
|
|
48
|
-
#
|
|
49
|
+
# Creates an error from an exception.
|
|
49
50
|
#
|
|
50
|
-
# @param exception [Exception]
|
|
51
|
-
# @param duration [Float] request duration in seconds
|
|
52
|
-
# @param request_id [String]
|
|
53
|
-
# @param url [String]
|
|
54
|
-
# @param http_method [Symbol, String]
|
|
55
|
-
# @param callback_args [Hash, nil] callback arguments
|
|
56
|
-
# @return [RequestError]
|
|
51
|
+
# @param exception [Exception] The exception that the request raised.
|
|
52
|
+
# @param duration [Float] The request duration in seconds.
|
|
53
|
+
# @param request_id [String] The request ID.
|
|
54
|
+
# @param url [String] The request URL.
|
|
55
|
+
# @param http_method [Symbol, String] The HTTP method.
|
|
56
|
+
# @param callback_args [Hash, nil] The callback arguments, with string keys.
|
|
57
|
+
# @return [RequestError] The error.
|
|
57
58
|
def from_exception(exception, duration:, request_id:, url:, http_method:, callback_args: nil)
|
|
58
59
|
type = error_type(exception)
|
|
59
60
|
|
|
@@ -70,13 +71,16 @@ module PatientHttp
|
|
|
70
71
|
)
|
|
71
72
|
end
|
|
72
73
|
|
|
73
|
-
#
|
|
74
|
+
# Returns the error type for an exception.
|
|
74
75
|
#
|
|
75
|
-
#
|
|
76
|
-
#
|
|
76
|
+
# `IO::TimeoutError` is a subclass of `IOError`, but its type is `:timeout`,
|
|
77
|
+
# not `:connection`.
|
|
78
|
+
#
|
|
79
|
+
# @param exception [Exception] The exception.
|
|
80
|
+
# @return [Symbol] The error type, one of {ERROR_TYPES}.
|
|
77
81
|
def error_type(exception)
|
|
78
82
|
case exception
|
|
79
|
-
in Async::TimeoutError
|
|
83
|
+
in Async::TimeoutError | IO::TimeoutError
|
|
80
84
|
:timeout
|
|
81
85
|
in OpenSSL::SSL::SSLError
|
|
82
86
|
:ssl
|
|
@@ -92,17 +96,17 @@ module PatientHttp
|
|
|
92
96
|
end
|
|
93
97
|
end
|
|
94
98
|
|
|
95
|
-
#
|
|
99
|
+
# Creates an error.
|
|
96
100
|
#
|
|
97
|
-
# @param class_name [String]
|
|
98
|
-
# @param message [String]
|
|
99
|
-
# @param backtrace [Array<String>]
|
|
100
|
-
# @param error_type [Symbol]
|
|
101
|
-
# @param duration [Float]
|
|
102
|
-
# @param request_id [String]
|
|
103
|
-
# @param url [String]
|
|
104
|
-
# @param http_method [Symbol, String] HTTP method
|
|
105
|
-
# @param callback_args [Hash, nil] callback arguments
|
|
101
|
+
# @param class_name [String] The name of the exception class.
|
|
102
|
+
# @param message [String] The exception message.
|
|
103
|
+
# @param backtrace [Array<String>] The exception backtrace.
|
|
104
|
+
# @param error_type [Symbol] The error type, one of {ERROR_TYPES}.
|
|
105
|
+
# @param duration [Float] The request duration in seconds.
|
|
106
|
+
# @param request_id [String] The unique request ID.
|
|
107
|
+
# @param url [String] The request URL.
|
|
108
|
+
# @param http_method [Symbol, String] The HTTP method.
|
|
109
|
+
# @param callback_args [Hash, nil] The callback arguments, with string keys.
|
|
106
110
|
def initialize(class_name:, message:, backtrace:, error_type:, duration:, request_id:, url:, http_method:,
|
|
107
111
|
callback_args: nil)
|
|
108
112
|
super(message)
|
|
@@ -116,9 +120,9 @@ module PatientHttp
|
|
|
116
120
|
@callback_args_data = callback_args || {}
|
|
117
121
|
end
|
|
118
122
|
|
|
119
|
-
#
|
|
123
|
+
# Returns the error as a JSON-compatible hash.
|
|
120
124
|
#
|
|
121
|
-
# @return [Hash]
|
|
125
|
+
# @return [Hash] The serialized error.
|
|
122
126
|
def as_json
|
|
123
127
|
{
|
|
124
128
|
"class_name" => @class_name,
|
|
@@ -133,16 +137,17 @@ module PatientHttp
|
|
|
133
137
|
}
|
|
134
138
|
end
|
|
135
139
|
|
|
136
|
-
#
|
|
140
|
+
# Returns the class of the exception that caused the error.
|
|
137
141
|
#
|
|
138
|
-
# @return [Class, nil]
|
|
142
|
+
# @return [Class, nil] The exception class, or `nil` if the class isn't
|
|
143
|
+
# defined in this process.
|
|
139
144
|
def error_class
|
|
140
145
|
ClassHelper.resolve_class_name(@class_name)
|
|
141
146
|
end
|
|
142
147
|
|
|
143
|
-
# Returns the callback arguments
|
|
148
|
+
# Returns the callback arguments that were passed with the request.
|
|
144
149
|
#
|
|
145
|
-
# @return [CallbackArgs]
|
|
150
|
+
# @return [CallbackArgs] The callback arguments.
|
|
146
151
|
def callback_args
|
|
147
152
|
@callback_args ||= CallbackArgs.load(@callback_args_data)
|
|
148
153
|
end
|