google-cloud-errors 1.1.0 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 18ed78008afa75f71ca59d67f78c2c4552f0d39cee095caab782ac19bd1c3f06
4
- data.tar.gz: 122901666de9dbd124d9c307231bad7243f950d183abe1ccd3778dec7b1851a8
3
+ metadata.gz: a6a61f37c71769003ead1eb14bcb92410f3f337fd35fb8b01ae5c42e9023f0f1
4
+ data.tar.gz: f40064d7121a5a5542921b5d63fa42846c739c3e0ef1458a572ce6d7429afd4d
5
5
  SHA512:
6
- metadata.gz: 10d7df4020a5719659f9b815783ec7144890ae93ccae4e2bbe956ca6061d0c93554402ec0ecdd08b13a367a6bdfc284dd2fb4885c9c560279f6ec5b397125260
7
- data.tar.gz: 5401e211e05ca46c3c69707cba913cdfc5583fe8ce5703ff13e78c0181545057cd75b805a34b520ee5ebbed4376cc9fc2324792372d4b4e1570ef8c8f67943d8
6
+ metadata.gz: 1467367e06d652f6b052e23d279db7e1380d8b9fc515c90b6e70ab21f633936eabf28855ee3fb56e27807d7911451c66a3cffa1a5e84566002f30d88ffadd108
7
+ data.tar.gz: 28fb6964f53e4cb349da6c7213154c3f810119cb2efaaad7280fb3040ccd458ef4be8b75bcfde0534b4d779ab0f92ca43076708c77c034a82c2b857dfbf4e12d
data/CONTRIBUTING.md CHANGED
@@ -124,5 +124,4 @@ $ bundle exec rake rubocop
124
124
  ## Code of Conduct
125
125
 
126
126
  Please note that this project is released with a Contributor Code of Conduct. By
127
- participating in this project you agree to abide by its terms. See
128
- {file:CODE_OF_CONDUCT.md Code of Conduct} for more information.
127
+ participating in this project you agree to abide by its terms. See {file:CODE_OF_CONDUCT.md Code of Conduct} for more information.
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Errors
19
- VERSION = "1.1.0".freeze
19
+ VERSION = "1.2.0".freeze
20
20
  end
21
21
  end
22
22
  end
@@ -118,6 +118,61 @@ module Google
118
118
  cause.status_details
119
119
  end
120
120
 
121
+ ##
122
+ # Returns the `::Google::Rpc::ErrorInfo` object present in `status_details` array,
123
+ # given that the following is true:
124
+ # * `status_details` exists and is an array
125
+ # * there is exactly one `::Google::Rpc::ErrorInfo` object in the `status_details` array
126
+ #
127
+ # @return [::Google::Rpc::ErrorInfo, nil]
128
+ def error_info
129
+ @error_info ||= if status_details.is_a? Array
130
+ error_infos = status_details.find_all { |status| status.is_a?(::Google::Rpc::ErrorInfo) }
131
+ if error_infos.length == 1
132
+ error_infos[0]
133
+ end
134
+ end
135
+ end
136
+
137
+ ##
138
+ # Returns the value of `domain` from the `::Google::Rpc::ErrorInfo`
139
+ # object, if it exists in the `status_details` array.
140
+ #
141
+ # This is typically present on errors originating from calls to an API
142
+ # over gRPC.
143
+ #
144
+ # @return [Object, nil]
145
+ def domain
146
+ return nil unless error_info.respond_to? :domain
147
+ error_info.domain
148
+ end
149
+
150
+ ##
151
+ # Returns the value of `reason` from the `::Google::Rpc::ErrorInfo`
152
+ # object, if it exists in the `status_details` array.
153
+ #
154
+ # This is typically present on errors originating from calls to an API
155
+ # over gRPC.
156
+ #
157
+ # @return [Object, nil]
158
+ def reason
159
+ return nil unless error_info.respond_to? :reason
160
+ error_info.reason
161
+ end
162
+
163
+ ##
164
+ # Returns the value of `metadata` from the `::Google::Rpc::ErrorInfo`
165
+ # object, if it exists in the `status_details` array.
166
+ #
167
+ # This is typically present on errors originating from calls to an API
168
+ # over gRPC.
169
+ #
170
+ # @return [Hash, nil]
171
+ def error_metadata
172
+ return nil unless error_info.respond_to? :metadata
173
+ error_info.metadata.to_h
174
+ end
175
+
121
176
  # @private Create a new error object from a client error
122
177
  def self.from_error error
123
178
  klass = if error.respond_to? :code
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-errors
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Moore
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-03-10 00:00:00.000000000 Z
12
+ date: 2021-09-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: autotest-suffix
@@ -186,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
186
  - !ruby/object:Gem::Version
187
187
  version: '0'
188
188
  requirements: []
189
- rubygems_version: 3.2.13
189
+ rubygems_version: 3.2.17
190
190
  signing_key:
191
191
  specification_version: 4
192
192
  summary: Error classes for google-cloud-ruby