google-cloud-errors 0.0.1 → 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: c454f54bb24cc8e46dd5b0953ea1d00ba3782ded1ad763443eefc9b82cd29c8a
4
- data.tar.gz: 3d16c10fc121886aa68f4aaca2dad4242b0349c526eacc57773dd271543f1073
3
+ metadata.gz: a6a61f37c71769003ead1eb14bcb92410f3f337fd35fb8b01ae5c42e9023f0f1
4
+ data.tar.gz: f40064d7121a5a5542921b5d63fa42846c739c3e0ef1458a572ce6d7429afd4d
5
5
  SHA512:
6
- metadata.gz: c0400faa491e0e3679eced016f634c29e3264181b1f04b15b71e7f98f088f3bf922a4a6c8000a5a5c2ceb058a3c5a9dda4d44c2ba84c9d629930f8ad12ee9d77
7
- data.tar.gz: 7be40dae2d36036d2eac8e68b827fdfcdab903972b2127e04b53254ffc25554f625d492a4a1b992bded9d8032d3819396a4ee065e53cec1cc1c1bafd18cb243c
6
+ metadata.gz: 1467367e06d652f6b052e23d279db7e1380d8b9fc515c90b6e70ab21f633936eabf28855ee3fb56e27807d7911451c66a3cffa1a5e84566002f30d88ffadd108
7
+ data.tar.gz: 28fb6964f53e4cb349da6c7213154c3f810119cb2efaaad7280fb3040ccd458ef4be8b75bcfde0534b4d779ab0f92ca43076708c77c034a82c2b857dfbf4e12d
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.4+. You may choose to
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,22 +45,9 @@ there is a small amount of setup:
45
45
 
46
46
  ```sh
47
47
  $ cd google-cloud-errors/
48
- $ bundle exec rake bundleupdate
48
+ $ bundle install
49
49
  ```
50
50
 
51
- ## Console
52
-
53
- In order to run code interactively, you can automatically load
54
- google-cloud and its dependencies in IRB. This requires that your
55
- developer environment has already been configured by following the steps
56
- described in the {file:AUTHENTICATION.md Authentication Guide}. An IRB console
57
- can be created with:
58
-
59
- ```sh
60
- $ cd google-cloud-errors/
61
- $ bundle exec rake console
62
- ```
63
-
64
51
  ## Google Cloud Tests
65
52
 
66
53
  Tests are very important part of google-cloud. All contributions
@@ -137,5 +124,4 @@ $ bundle exec rake rubocop
137
124
  ## Code of Conduct
138
125
 
139
126
  Please note that this project is released with a Contributor Code of Conduct. By
140
- participating in this project you agree to abide by its terms. See
141
- {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.4+.
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.4 and
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.
@@ -1,4 +1,4 @@
1
- # Copyright 2016 Google LLC
1
+ # Copyright 2020 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Errors
19
- VERSION = "0.0.1".freeze
19
+ VERSION = "1.2.0".freeze
20
20
  end
21
21
  end
22
22
  end
@@ -1,4 +1,4 @@
1
- # Copyright 2015 Google LLC
1
+ # Copyright 2020 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ module Google
36
36
  #
37
37
  # @return [Object, nil]
38
38
  def status_code
39
- return nil unless cause&.respond_to? :status_code
39
+ return nil unless cause.respond_to? :status_code
40
40
  cause.status_code
41
41
  end
42
42
 
@@ -49,7 +49,7 @@ module Google
49
49
  #
50
50
  # @return [Object, nil]
51
51
  def body
52
- return nil unless cause&.respond_to? :body
52
+ return nil unless cause.respond_to? :body
53
53
  cause.body
54
54
  end
55
55
 
@@ -62,7 +62,7 @@ module Google
62
62
  #
63
63
  # @return [Object, nil]
64
64
  def header
65
- return nil unless cause&.respond_to? :header
65
+ return nil unless cause.respond_to? :header
66
66
  cause.header
67
67
  end
68
68
 
@@ -75,7 +75,7 @@ module Google
75
75
  #
76
76
  # @return [Object, nil]
77
77
  def code
78
- return nil unless cause&.respond_to? :code
78
+ return nil unless cause.respond_to? :code
79
79
  cause.code
80
80
  end
81
81
 
@@ -88,7 +88,7 @@ module Google
88
88
  #
89
89
  # @return [Object, nil]
90
90
  def details
91
- return nil unless cause&.respond_to? :details
91
+ return nil unless cause.respond_to? :details
92
92
  cause.details
93
93
  end
94
94
 
@@ -101,7 +101,7 @@ module Google
101
101
  #
102
102
  # @return [Object, nil]
103
103
  def metadata
104
- return nil unless cause&.respond_to? :metadata
104
+ return nil unless cause.respond_to? :metadata
105
105
  cause.metadata
106
106
  end
107
107
 
@@ -114,10 +114,65 @@ module Google
114
114
  #
115
115
  # @return [Object, nil]
116
116
  def status_details
117
- return nil unless cause&.respond_to? :status_details
117
+ return nil unless cause.respond_to? :status_details
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
@@ -1,4 +1,4 @@
1
- # Copyright 2019 Google LLC
1
+ # Copyright 2020 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
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: 0.0.1
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: 2019-12-27 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
@@ -31,28 +31,28 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: 1.24.0
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.24.0
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.10'
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.10'
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.4'
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.1.2
189
+ rubygems_version: 3.2.17
190
190
  signing_key:
191
191
  specification_version: 4
192
192
  summary: Error classes for google-cloud-ruby