contentstack 0.8.1 → 0.8.2

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: 9e8661a014dc2bdfc647108d4f28b52735e7a4676b8ace13459ab2d0e7a86763
4
- data.tar.gz: dc461c0e7ee499b02adc8aeb2b6af12681e18b1702b8eaeb5d8bab971dd63a3d
3
+ metadata.gz: 3c53e5f1e0ff64e24114c733c40b0d294a0b3670e9794cf98d85f7379a995216
4
+ data.tar.gz: 961ecab5684492aacdbeee5fdb281b7b8f70026bc138077cbcba1ef64a4fdfd6
5
5
  SHA512:
6
- metadata.gz: 98e41cf1ecd666cb12fed8890283bba0e267e2261162284e3b0bcd2693d0d66ec7e37a908fd9351479ae9ac90d65b0bf1d87fd29cc96a43db977cb594071cc5f
7
- data.tar.gz: 426549e776c6308ab1cb1e79ee9a8e7eed0e23b2fee88f30c5efca95332038f4f033d5590e529a6990a75ea371b521691af5e00b188718a674dd6f282db183f5
6
+ metadata.gz: 3d394f96d11ed7b3c8bd3e0377c389df1c9b26f598d6d3089a5a022a1b2d0fdedebd4f4e854d2aeba2f14933ae3c8b7bd82a13a72e6a40dee5885d18a4881091
7
+ data.tar.gz: a3b2a7d25231364a60c7489b76bd4af81c28dd5d816686e2bf942e1224aba6af5a9777e91a8ccc54f14367a1c776de7bceeb11a655ab0884467b321d9db11163
data/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
1
  ## CHANGELOG
2
2
 
3
- ## Version 0.8.0
3
+ ## Version 0.8.2
4
+ ### Date: 12th-January-2026
5
+ ### Improved error messages
6
+ -
7
+
8
+ ------------------------------------------------
9
+
10
+ ## Version 0.8.1
4
11
  ### Date: 05th-January-2026
5
12
  ### Security Bug
6
13
  - Fixed snyk security issues and updated license year
data/Gemfile.lock CHANGED
@@ -68,6 +68,7 @@ GEM
68
68
  simplecov_json_formatter (0.1.4)
69
69
  tzinfo (2.0.6)
70
70
  concurrent-ruby (~> 1.0)
71
+ uri (1.1.1)
71
72
  webmock (3.11.3)
72
73
  addressable (>= 2.3.6)
73
74
  crack (>= 0.3.2)
@@ -76,6 +77,7 @@ GEM
76
77
 
77
78
  PLATFORMS
78
79
  arm64-darwin-22
80
+ arm64-darwin-24
79
81
 
80
82
  DEPENDENCIES
81
83
  contentstack!
@@ -82,7 +82,7 @@ module Contentstack
82
82
  sleep(retryDelay_in_seconds.to_i) #sleep method requires time in seconds as parameter
83
83
  response = fetch_retry(path, query, (count + 1))
84
84
  else
85
- raise Contentstack::Error.new(response) #Retry Limit exceeded
85
+ raise Contentstack::Error.new(Contentstack::ErrorMessages.request_failed(response)) #Retry Limit exceeded
86
86
  end
87
87
  else
88
88
  to_render_content(response)
@@ -125,7 +125,7 @@ module Contentstack
125
125
  error_response = JSON.parse(response.string)
126
126
  error_status = {"status_code" => response.status[0], "status_message" => response.status[1]}
127
127
  error = error_response.merge(error_status)
128
- raise Contentstack::Error.new(error.to_s)
128
+ raise Contentstack::Error.new(Contentstack::ErrorMessages.request_error(error))
129
129
  end
130
130
  end
131
131
 
@@ -165,7 +165,7 @@ module Contentstack
165
165
  error_response = JSON.parse(response.string)
166
166
  error_status = {"status_code" => response.status[0], "status_message" => response.status[1]}
167
167
  error = error_response.merge(error_status)
168
- raise Contentstack::Error.new(error.to_s)
168
+ raise Contentstack::Error.new(Contentstack::ErrorMessages.request_error(error))
169
169
  end
170
170
  end
171
171
 
@@ -10,12 +10,12 @@ module Contentstack
10
10
  attr_reader :region, :host
11
11
  # Initialize "Contentstack" Client instance
12
12
  def initialize(api_key, delivery_token, environment, options={})
13
- raise Contentstack::Error.new("Api Key is not valid") if api_key.class != String
14
- raise Contentstack::Error.new("Api Key Field Should not be Empty") if api_key.empty?
15
- raise Contentstack::Error.new("Delivery Token is not valid") if delivery_token.class != String
16
- raise Contentstack::Error.new("Delivery Token Field Should not be Empty") if delivery_token.empty?
17
- raise Contentstack::Error.new("Envirnoment Field is not valid") if environment.class != String
18
- raise Contentstack::Error.new("Envirnoment Field Should not be Empty") if environment.empty?
13
+ raise Contentstack::Error.new(Contentstack::ErrorMessages::API_KEY_INVALID) if api_key.class != String
14
+ raise Contentstack::Error.new(Contentstack::ErrorMessages::API_KEY_REQUIRED) if api_key.empty?
15
+ raise Contentstack::Error.new(Contentstack::ErrorMessages::DELIVERY_TOKEN_INVALID) if delivery_token.class != String
16
+ raise Contentstack::Error.new(Contentstack::ErrorMessages::DELIVERY_TOKEN_REQUIRED) if delivery_token.empty?
17
+ raise Contentstack::Error.new(Contentstack::ErrorMessages::ENVIRONMENT_INVALID) if environment.class != String
18
+ raise Contentstack::Error.new(Contentstack::ErrorMessages::ENVIRONMENT_REQUIRED) if environment.empty?
19
19
  @region = options[:region].nil? ? Contentstack::Region::US : options[:region]
20
20
  # @host = options[:host].nil? ? get_default_region_hosts(@region) : options[:host] #removed for not supporting custom host with regions
21
21
  @host = get_host_by_region(@region, options) # Added new method for custom host support with different regions
@@ -32,8 +32,8 @@ module Contentstack
32
32
  "retryLimit"=> @retryLimit,
33
33
  "errorRetry" => @errorRetry
34
34
  }
35
- raise Contentstack::Error.new("Proxy URL Should not be Empty") if @proxy_details.present? && @proxy_details[:url].empty?
36
- raise Contentstack::Error.new("Proxy Port Should not be Empty") if @proxy_details.present? && @proxy_details[:port].empty?
35
+ raise Contentstack::Error.new(Contentstack::ErrorMessages::PROXY_URL_REQUIRED) if @proxy_details.present? && @proxy_details[:url].empty?
36
+ raise Contentstack::Error.new(Contentstack::ErrorMessages::PROXY_PORT_REQUIRED) if @proxy_details.present? && @proxy_details[:port].empty?
37
37
  API.init_api(api_key, delivery_token, environment, @host, @branch, @live_preview, @proxy_details, retry_options)
38
38
  end
39
39
 
@@ -1,4 +1,24 @@
1
1
  module Contentstack
2
+ # Centralized error messages for the SDK
3
+ module ErrorMessages
4
+ API_KEY_INVALID = "API Key is invalid. Provide a valid API Key and try again."
5
+ API_KEY_REQUIRED = "API Key is required. Provide a valid API Key and try again."
6
+ DELIVERY_TOKEN_INVALID = "Delivery Token is invalid. Provide a valid Delivery Token and try again."
7
+ DELIVERY_TOKEN_REQUIRED = "Delivery Token is required. Provide a valid Delivery Token and try again."
8
+ ENVIRONMENT_INVALID = "Environment is invalid. Provide a valid Environment and try again."
9
+ ENVIRONMENT_REQUIRED = "Environment is required. Provide a valid Environment and try again."
10
+ PROXY_URL_REQUIRED = "Proxy URL is required. Provide a valid Proxy URL and try again."
11
+ PROXY_PORT_REQUIRED = "Proxy Port is required. Provide a valid Proxy Port and try again."
12
+
13
+ def self.request_failed(response)
14
+ "The request could not be completed due to #{response}. Review the details and try again."
15
+ end
16
+
17
+ def self.request_error(error)
18
+ "The request encountered an issue due to #{error}. Review the details and try again."
19
+ end
20
+ end
21
+
2
22
  class Error < StandardError
3
23
  def initialize(msg="Something Went Wrong.")
4
24
  super
@@ -1,3 +1,3 @@
1
1
  module Contentstack
2
- VERSION = "0.8.1"
2
+ VERSION = "0.8.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contentstack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Contentstack
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-01-05 00:00:00.000000000 Z
11
+ date: 2026-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport