google-cloud-errors 1.2.0 → 1.3.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: a6a61f37c71769003ead1eb14bcb92410f3f337fd35fb8b01ae5c42e9023f0f1
4
- data.tar.gz: f40064d7121a5a5542921b5d63fa42846c739c3e0ef1458a572ce6d7429afd4d
3
+ metadata.gz: 0ab6400a7d633ba4c9bb30de49bc2b23a5824530fa02a1f88aa151ff328487ab
4
+ data.tar.gz: 77459bb92f7408eb68b9d02ed6b96cd4d3f183d213c27b1eac36086129957424
5
5
  SHA512:
6
- metadata.gz: 1467367e06d652f6b052e23d279db7e1380d8b9fc515c90b6e70ab21f633936eabf28855ee3fb56e27807d7911451c66a3cffa1a5e84566002f30d88ffadd108
7
- data.tar.gz: 28fb6964f53e4cb349da6c7213154c3f810119cb2efaaad7280fb3040ccd458ef4be8b75bcfde0534b4d779ab0f92ca43076708c77c034a82c2b857dfbf4e12d
6
+ metadata.gz: f9cbd068fecd4fa411fd008bc519460366900be46f774ead0c5e92b399f46c8ec1f9cf02e2971dafdc86106f177e48073720faf2a6135c09f8bc80bf8eded0e6
7
+ data.tar.gz: 5f54fe580d61ce5e0d1b80b13a461e3d299c888e770646328df796e662093c0e1a1cfae1996a3b5c91307673e372400f267caa0d0bb54c67c5d1fbdb51947b10
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Errors
19
- VERSION = "1.2.0".freeze
19
+ VERSION = "1.3.0".freeze
20
20
  end
21
21
  end
22
22
  end
@@ -23,6 +23,8 @@ module Google
23
23
  ##
24
24
  # Construct a new Google::Cloud::Error object, optionally passing in a
25
25
  # message.
26
+ #
27
+ # @param msg [String, nil] an error message
26
28
  def initialize msg = nil
27
29
  super
28
30
  end
@@ -119,19 +121,26 @@ module Google
119
121
  end
120
122
 
121
123
  ##
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
124
+ # Returns the `::Google::Rpc::ErrorInfo` object present in the `status_details`
125
+ # or `details` array, given that the following is true:
126
+ # * either `status_details` or `details` exists and is an array
127
+ # * there is exactly one `::Google::Rpc::ErrorInfo` object in that array.
128
+ # Looks in `status_details` first, then in `details`.
126
129
  #
127
130
  # @return [::Google::Rpc::ErrorInfo, nil]
128
131
  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
132
+ @error_info ||= begin
133
+ check_property = lambda do |prop|
134
+ if prop.is_a? Array
135
+ error_infos = prop.find_all { |status| status.is_a?(::Google::Rpc::ErrorInfo) }
136
+ if error_infos.length == 1
137
+ error_infos[0]
138
+ end
139
+ end
140
+ end
141
+
142
+ check_property.call(status_details) || check_property.call(details)
143
+ end
135
144
  end
136
145
 
137
146
  ##
@@ -272,12 +281,6 @@ module Google
272
281
  class PermissionDeniedError < Error
273
282
  end
274
283
 
275
- ##
276
- # Unauthenticated indicates the request does not have valid
277
- # authentication credentials for the operation.
278
- class UnauthenticatedError < Error
279
- end
280
-
281
284
  ##
282
285
  # ResourceExhausted indicates some resource has been exhausted, perhaps
283
286
  # a per-user quota, or perhaps the entire file system is out of space.
@@ -363,5 +366,11 @@ module Google
363
366
  # DataLoss indicates unrecoverable data loss or corruption.
364
367
  class DataLossError < Error
365
368
  end
369
+
370
+ ##
371
+ # Unauthenticated indicates the request does not have valid
372
+ # authentication credentials for the operation.
373
+ class UnauthenticatedError < Error
374
+ end
366
375
  end
367
376
  end
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.2.0
4
+ version: 1.3.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-09-20 00:00:00.000000000 Z
12
+ date: 2022-09-13 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.17
189
+ rubygems_version: 3.3.14
190
190
  signing_key:
191
191
  specification_version: 4
192
192
  summary: Error classes for google-cloud-ruby