google-cloud-errors 1.0.1 → 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 +4 -4
- data/CONTRIBUTING.md +3 -4
- data/README.md +2 -2
- data/lib/google/cloud/errors/version.rb +1 -1
- data/lib/google/cloud/errors.rb +77 -13
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ab6400a7d633ba4c9bb30de49bc2b23a5824530fa02a1f88aa151ff328487ab
|
4
|
+
data.tar.gz: 77459bb92f7408eb68b9d02ed6b96cd4d3f183d213c27b1eac36086129957424
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9cbd068fecd4fa411fd008bc519460366900be46f774ead0c5e92b399f46c8ec1f9cf02e2971dafdc86106f177e48073720faf2a6135c09f8bc80bf8eded0e6
|
7
|
+
data.tar.gz: 5f54fe580d61ce5e0d1b80b13a461e3d299c888e770646328df796e662093c0e1a1cfae1996a3b5c91307673e372400f267caa0d0bb54c67c5d1fbdb51947b10
|
data/CONTRIBUTING.md
CHANGED
@@ -24,7 +24,7 @@ be able to accept your pull requests.
|
|
24
24
|
In order to use the google-cloud console and run the project's tests,
|
25
25
|
there is a small amount of setup:
|
26
26
|
|
27
|
-
1. Install Ruby. google-cloud requires Ruby 2.
|
27
|
+
1. Install Ruby. google-cloud requires Ruby 2.5+. You may choose to
|
28
28
|
manage your Ruby and gem installations with [RVM](https://rvm.io/),
|
29
29
|
[rbenv](https://github.com/rbenv/rbenv), or
|
30
30
|
[chruby](https://github.com/postmodern/chruby).
|
@@ -45,7 +45,7 @@ there is a small amount of setup:
|
|
45
45
|
|
46
46
|
```sh
|
47
47
|
$ cd google-cloud-errors/
|
48
|
-
$ bundle
|
48
|
+
$ bundle install
|
49
49
|
```
|
50
50
|
|
51
51
|
## Google Cloud Tests
|
@@ -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.
|
data/README.md
CHANGED
@@ -9,11 +9,11 @@ information about Google Cloud gems.
|
|
9
9
|
|
10
10
|
## Supported Ruby Versions
|
11
11
|
|
12
|
-
This library is supported on Ruby 2.
|
12
|
+
This library is supported on Ruby 2.5+.
|
13
13
|
|
14
14
|
Google provides official support for Ruby versions that are actively supported
|
15
15
|
by Ruby Core—that is, Ruby versions that are either in normal maintenance or in
|
16
|
-
security maintenance, and not end of life. Currently, this means Ruby 2.
|
16
|
+
security maintenance, and not end of life. Currently, this means Ruby 2.5 and
|
17
17
|
later. Older versions of Ruby _may_ still work, but are unsupported and not
|
18
18
|
recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details
|
19
19
|
about the Ruby support schedule.
|
data/lib/google/cloud/errors.rb
CHANGED
@@ -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
|
@@ -36,7 +38,7 @@ module Google
|
|
36
38
|
#
|
37
39
|
# @return [Object, nil]
|
38
40
|
def status_code
|
39
|
-
return nil unless cause
|
41
|
+
return nil unless cause.respond_to? :status_code
|
40
42
|
cause.status_code
|
41
43
|
end
|
42
44
|
|
@@ -49,7 +51,7 @@ module Google
|
|
49
51
|
#
|
50
52
|
# @return [Object, nil]
|
51
53
|
def body
|
52
|
-
return nil unless cause
|
54
|
+
return nil unless cause.respond_to? :body
|
53
55
|
cause.body
|
54
56
|
end
|
55
57
|
|
@@ -62,7 +64,7 @@ module Google
|
|
62
64
|
#
|
63
65
|
# @return [Object, nil]
|
64
66
|
def header
|
65
|
-
return nil unless cause
|
67
|
+
return nil unless cause.respond_to? :header
|
66
68
|
cause.header
|
67
69
|
end
|
68
70
|
|
@@ -75,7 +77,7 @@ module Google
|
|
75
77
|
#
|
76
78
|
# @return [Object, nil]
|
77
79
|
def code
|
78
|
-
return nil unless cause
|
80
|
+
return nil unless cause.respond_to? :code
|
79
81
|
cause.code
|
80
82
|
end
|
81
83
|
|
@@ -88,7 +90,7 @@ module Google
|
|
88
90
|
#
|
89
91
|
# @return [Object, nil]
|
90
92
|
def details
|
91
|
-
return nil unless cause
|
93
|
+
return nil unless cause.respond_to? :details
|
92
94
|
cause.details
|
93
95
|
end
|
94
96
|
|
@@ -101,7 +103,7 @@ module Google
|
|
101
103
|
#
|
102
104
|
# @return [Object, nil]
|
103
105
|
def metadata
|
104
|
-
return nil unless cause
|
106
|
+
return nil unless cause.respond_to? :metadata
|
105
107
|
cause.metadata
|
106
108
|
end
|
107
109
|
|
@@ -114,10 +116,72 @@ module Google
|
|
114
116
|
#
|
115
117
|
# @return [Object, nil]
|
116
118
|
def status_details
|
117
|
-
return nil unless cause
|
119
|
+
return nil unless cause.respond_to? :status_details
|
118
120
|
cause.status_details
|
119
121
|
end
|
120
122
|
|
123
|
+
##
|
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`.
|
129
|
+
#
|
130
|
+
# @return [::Google::Rpc::ErrorInfo, nil]
|
131
|
+
def error_info
|
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
|
144
|
+
end
|
145
|
+
|
146
|
+
##
|
147
|
+
# Returns the value of `domain` from the `::Google::Rpc::ErrorInfo`
|
148
|
+
# object, if it exists in the `status_details` array.
|
149
|
+
#
|
150
|
+
# This is typically present on errors originating from calls to an API
|
151
|
+
# over gRPC.
|
152
|
+
#
|
153
|
+
# @return [Object, nil]
|
154
|
+
def domain
|
155
|
+
return nil unless error_info.respond_to? :domain
|
156
|
+
error_info.domain
|
157
|
+
end
|
158
|
+
|
159
|
+
##
|
160
|
+
# Returns the value of `reason` from the `::Google::Rpc::ErrorInfo`
|
161
|
+
# object, if it exists in the `status_details` array.
|
162
|
+
#
|
163
|
+
# This is typically present on errors originating from calls to an API
|
164
|
+
# over gRPC.
|
165
|
+
#
|
166
|
+
# @return [Object, nil]
|
167
|
+
def reason
|
168
|
+
return nil unless error_info.respond_to? :reason
|
169
|
+
error_info.reason
|
170
|
+
end
|
171
|
+
|
172
|
+
##
|
173
|
+
# Returns the value of `metadata` from the `::Google::Rpc::ErrorInfo`
|
174
|
+
# object, if it exists in the `status_details` array.
|
175
|
+
#
|
176
|
+
# This is typically present on errors originating from calls to an API
|
177
|
+
# over gRPC.
|
178
|
+
#
|
179
|
+
# @return [Hash, nil]
|
180
|
+
def error_metadata
|
181
|
+
return nil unless error_info.respond_to? :metadata
|
182
|
+
error_info.metadata.to_h
|
183
|
+
end
|
184
|
+
|
121
185
|
# @private Create a new error object from a client error
|
122
186
|
def self.from_error error
|
123
187
|
klass = if error.respond_to? :code
|
@@ -217,12 +281,6 @@ module Google
|
|
217
281
|
class PermissionDeniedError < Error
|
218
282
|
end
|
219
283
|
|
220
|
-
##
|
221
|
-
# Unauthenticated indicates the request does not have valid
|
222
|
-
# authentication credentials for the operation.
|
223
|
-
class UnauthenticatedError < Error
|
224
|
-
end
|
225
|
-
|
226
284
|
##
|
227
285
|
# ResourceExhausted indicates some resource has been exhausted, perhaps
|
228
286
|
# a per-user quota, or perhaps the entire file system is out of space.
|
@@ -308,5 +366,11 @@ module Google
|
|
308
366
|
# DataLoss indicates unrecoverable data loss or corruption.
|
309
367
|
class DataLossError < Error
|
310
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
|
311
375
|
end
|
312
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.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:
|
12
|
+
date: 2022-09-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: autotest-suffix
|
@@ -31,28 +31,28 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 1.
|
34
|
+
version: 1.25.1
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: 1.
|
41
|
+
version: 1.25.1
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: minitest
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '5.
|
48
|
+
version: '5.14'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '5.
|
55
|
+
version: '5.14'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: minitest-autotest
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -179,14 +179,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
179
179
|
requirements:
|
180
180
|
- - ">="
|
181
181
|
- !ruby/object:Gem::Version
|
182
|
-
version: '2.
|
182
|
+
version: '2.5'
|
183
183
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
185
|
- - ">="
|
186
186
|
- !ruby/object:Gem::Version
|
187
187
|
version: '0'
|
188
188
|
requirements: []
|
189
|
-
rubygems_version: 3.
|
189
|
+
rubygems_version: 3.3.14
|
190
190
|
signing_key:
|
191
191
|
specification_version: 4
|
192
192
|
summary: Error classes for google-cloud-ruby
|