Skip to content

Commit

Permalink
feat: add alias for details field in Rest Error (#928)
Browse files Browse the repository at this point in the history
  • Loading branch information
viacheslav-rostovtsev authored Feb 27, 2023
1 parent beb0f04 commit f1c2e73
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions gapic-common/lib/gapic/rest/error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

require "json"
require "gapic/common/error"
require "google/protobuf/well_known_types"
# Not technically required but GRPC counterpart loads it and so should we for test parity
require "google/rpc/error_details_pb"

module Gapic
module Rest
Expand All @@ -25,6 +28,8 @@ class Error < ::Gapic::Common::Error
attr_reader :status
# @return [Object, nil] the details as parsed from the response body
attr_reader :details
# The Cloud error wrapper expect to see a `status_details` property
alias status_details details
# @return [Object, nil] the headers of the REST error
attr_reader :headers
# The Cloud error wrapper expect to see a `header` property
Expand Down
2 changes: 2 additions & 0 deletions gapic-common/test/gapic/rest/error_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ def test_wrap_faraday
refute_nil grpc_help
assert_equal @help.links.first.description, grpc_help.links.first&.description
assert_equal @help.links.first.url, grpc_help.links.first&.url

assert_equal gapic_err.details, gapic_err.status_details
end

# Tests that the message and the status code from within body
Expand Down

0 comments on commit f1c2e73

Please sign in to comment.