vultr 2.1.2 → 2.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: 9609cbba7070cc71e250e9595e9b44a6ab7cb68139ff5abe9d9ccb50751a9310
4
- data.tar.gz: 0ca8b5e6ef4873af6d6a48ad9eae2b62f2ee0858e44f91bf3b07c301c3bf1848
3
+ metadata.gz: a0d402981fa6f60678c517de136a422346775bf6ac89b23b2a21b3645c503dfa
4
+ data.tar.gz: 0ff0865a2aa2ff5ddf8c8bde2bd74071cc5625d2384635105c8e17059262ad60
5
5
  SHA512:
6
- metadata.gz: e53fd059d2932b6a50dfb5e5d80f12aa289bfab9415a7c8a3901b1cc161e572d75e5429e2563a092a1c6e96d0377636a855aa5161af818bf56052063fc1391ed
7
- data.tar.gz: e2229a47f6a1eee7165770327a30ec6e95900e5849128086a1bcf6695f695857d512c4ae9c7c4695b5469682d2b2663e79190ce32f626fc596acbbd234e4d0ab
6
+ metadata.gz: abf9d0381481d48e89bae2a6a984cfb5ba3932d466ab55718c239a336af4b5bf61ca4012300c2b7d2895cad4e492f5187bf6c03108ce9e112e7f416069060088
7
+ data.tar.gz: 206dc5633de146163e059a9df98ceaa485299458d4b580a6069f15aea750d0e2b6dccea146ab474d236d36e07ff50bc27b127feeca0e949ce20aedfdd79aef10
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ == Unreleased
2
+
3
+ == 2.2.0 / 2026-11-24
4
+
5
+ * Raise a `Vultr::Error` subclass for each status the API answers with: `BadRequest` (400), `Unauthorized` (401), `Forbidden` (403), `NotFound` (404), `RateLimited` (429 and 503) and `ServerError` (500). Rescuing `Vultr::Error` still catches them all.
6
+
1
7
  == 2.1.2 / 2026-9-15
2
8
 
3
9
  * Fix Collection#each raising NameError
data/lib/vultr/error.rb CHANGED
@@ -1,4 +1,18 @@
1
1
  module Vultr
2
2
  class Error < StandardError
3
3
  end
4
+
5
+ # One per status the API answers with, so callers can rescue a status rather than
6
+ # match the message. Each is a Vultr::Error, so rescuing that still catches them all.
7
+ class BadRequest < Error; end
8
+
9
+ class Unauthorized < Error; end
10
+
11
+ class Forbidden < Error; end
12
+
13
+ class NotFound < Error; end
14
+
15
+ class RateLimited < Error; end
16
+
17
+ class ServerError < Error; end
4
18
  end
@@ -31,19 +31,19 @@ module Vultr
31
31
  def handle_response(response)
32
32
  case response.status
33
33
  when 400
34
- raise Error, "Your request was malformed. #{response.body["error"]}"
34
+ raise BadRequest, "Your request was malformed. #{response.body["error"]}"
35
35
  when 401
36
- raise Error, "You did not supply valid authentication credentials. #{response.body["error"]}"
36
+ raise Unauthorized, "You did not supply valid authentication credentials. #{response.body["error"]}"
37
37
  when 403
38
- raise Error, "You are not allowed to perform that action. #{response.body["error"]}"
38
+ raise Forbidden, "You are not allowed to perform that action. #{response.body["error"]}"
39
39
  when 404
40
- raise Error, "No results were found for your request. #{response.body["error"]}"
40
+ raise NotFound, "No results were found for your request. #{response.body["error"]}"
41
41
  when 429
42
- raise Error, "Your request exceeded the API rate limit. #{response.body["error"]}"
42
+ raise RateLimited, "Your request exceeded the API rate limit. #{response.body["error"]}"
43
43
  when 500
44
- raise Error, "We were unable to perform the request due to server-side problems. #{response.body["error"]}"
44
+ raise ServerError, "We were unable to perform the request due to server-side problems. #{response.body["error"]}"
45
45
  when 503
46
- raise Error, "You have been rate limited for sending more than 20 requests per second. #{response.body["error"]}"
46
+ raise RateLimited, "You have been rate limited for sending more than 20 requests per second. #{response.body["error"]}"
47
47
  end
48
48
 
49
49
  response
data/lib/vultr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Vultr
2
- VERSION = "2.1.2"
2
+ VERSION = "2.2.0"
3
3
  end
data/lib/vultr.rb CHANGED
@@ -5,6 +5,12 @@ module Vultr
5
5
  autoload :Client, "vultr/client"
6
6
  autoload :Collection, "vultr/collection"
7
7
  autoload :Error, "vultr/error"
8
+ autoload :BadRequest, "vultr/error"
9
+ autoload :Unauthorized, "vultr/error"
10
+ autoload :Forbidden, "vultr/error"
11
+ autoload :NotFound, "vultr/error"
12
+ autoload :RateLimited, "vultr/error"
13
+ autoload :ServerError, "vultr/error"
8
14
  autoload :Middleware, "vultr/middleware"
9
15
  autoload :Resource, "vultr/resource"
10
16
  autoload :Object, "vultr/object"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vultr
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gao Jiangmiao
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  requirements: []
126
- rubygems_version: 4.0.18
126
+ rubygems_version: 4.0.20
127
127
  specification_version: 4
128
128
  summary: Ruby bindings for VULTR API.
129
129
  test_files: []