From f1c2e73219453e497b6ec2dc807a907e939e1342 Mon Sep 17 00:00:00 2001 From: Viacheslav Rostovtsev <58152857+viacheslav-rostovtsev@users.noreply.github.com> Date: Mon, 27 Feb 2023 18:49:00 +0000 Subject: [PATCH] feat: add alias for details field in Rest Error (#928) --- gapic-common/lib/gapic/rest/error.rb | 5 +++++ gapic-common/test/gapic/rest/error_test.rb | 2 ++ 2 files changed, 7 insertions(+) diff --git a/gapic-common/lib/gapic/rest/error.rb b/gapic-common/lib/gapic/rest/error.rb index 83c12ceaa..910604b1b 100644 --- a/gapic-common/lib/gapic/rest/error.rb +++ b/gapic-common/lib/gapic/rest/error.rb @@ -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 @@ -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 diff --git a/gapic-common/test/gapic/rest/error_test.rb b/gapic-common/test/gapic/rest/error_test.rb index fcc2ba7c4..6593db17b 100644 --- a/gapic-common/test/gapic/rest/error_test.rb +++ b/gapic-common/test/gapic/rest/error_test.rb @@ -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