Skip to content

Commit

Permalink
false body when response body is possibly nil
Browse files Browse the repository at this point in the history
  • Loading branch information
yawboakye committed Jun 26, 2024
1 parent 2b04381 commit ed4e496
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/vigiles/archive/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def initialize(stack_depth, max_stack_depth)
end
end

sig { params(rack_response: Rack::Response).returns(Types::Payload) }
sig { params(rack_response: Rack::Response).returns(T.nilable(Types::Payload)) }
private_class_method def self.extract_payload(rack_response)
case (body = rack_response.body)
when Array
Expand All @@ -63,7 +63,7 @@ def initialize(stack_depth, max_stack_depth)
{ __false_body: extracted_body }
end
else
{ __false_body: :unknown_response_payload_type }
{ __false_body: :unknown_response_payload_type, body_class: body.class.name }
end
end

Expand All @@ -73,7 +73,7 @@ def self.from(res)
rack_response: res,
content_type: res.headers["Content-Type"] || "unknown_content_type",
headers: res.headers.as_json,
payload: extract_payload(res),
payload: extract_payload(res) || {__false_body: :body_may_be_nil},
status: res.status
)
end
Expand Down

0 comments on commit ed4e496

Please sign in to comment.