translator-text 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8632db69acab569b667be95a710ddfb4063475a820160008248099d36d0b42fc
4
- data.tar.gz: d0bc41f634efd36ed604f439036188e70f3a1952d79952f650449a448c0cb535
3
+ metadata.gz: 402064d43803ff2cdf50582b924de32b0a2252fa537a9bde2a9d9aff1eafc206
4
+ data.tar.gz: f297a6cf08cbeddd475a971c94e2564e03bddb7b5d2d53a338b1853ecb46014f
5
5
  SHA512:
6
- metadata.gz: 2286a74057def86c7fae4ed2f6e8e9b4ebb15e3d23a38a6dbf74533ac6e079fc023764270cb8f3930e2803d8d17e4b9505a7396d3c02ac78c6a843f2241e759b
7
- data.tar.gz: 5edd026d712c585b93e170644424f73da279c1dad6314250a99a153a4fcca9d1ea2c7216c02bed6f068d7c6864400c4ad164035586d46ad47d79efd4682259e0
6
+ metadata.gz: 2133346bf4f959758e2ace99cfb2ef4c78aa057c248115ea82725d4b5e885019c4e36b380af3514e3e32467179261b28b5fe8f4829900e09318c462f2a5a7a7d
7
+ data.tar.gz: a315e3b0e877ddfe1ad399761e3ba5cec4b1d329ef5fd1554306733aa42c27bf5b1cd03e47b8cb68e5d09945b6a966e30b8df7505aad656e67dc6b9d9ba44d9a
data/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.3.1] - 2024-03-05
8
+ ### Fixes
9
+ - Better support of errors
10
+
7
11
  ## [0.3.0] - 2023-11-15
8
12
  ### Changed
9
13
  - Add support of the COGNITIVE_SUBSCRIPTION_REGION
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- translator-text (0.3.0)
4
+ translator-text (0.3.1)
5
5
  dry-struct (~> 1)
6
6
  httparty (~> 0.21)
7
7
 
@@ -93,22 +93,19 @@ module TranslatorText
93
93
  # If success, return the response body
94
94
  # If failure, raise an error
95
95
  def handle_response(response)
96
- case response.code
97
- when 200..299
98
- response
99
- else
100
- if response.request.format == :json
101
- raise ServiceError.new(
102
- code: response['error']['code'],
103
- message: response['error']['message']
104
- )
105
- else
106
- raise NetError.new(
107
- code: response.code,
108
- message: response.response.message
109
- )
110
- end
96
+ return response if response.code.between?(200, 299)
97
+
98
+ if response.request.format == :json && response['error']
99
+ raise ServiceError.new(
100
+ code: response['error']['code'],
101
+ message: response['error']['message']
102
+ )
111
103
  end
104
+
105
+ raise NetError.new(
106
+ code: response.code,
107
+ message: response.response.message
108
+ )
112
109
  end
113
110
 
114
111
  def headers
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TranslatorText
4
- VERSION = '0.3.0'
4
+ VERSION = '0.3.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: translator-text
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aymeric Brisse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-15 00:00:00.000000000 Z
11
+ date: 2024-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-struct