glia-errors 0.10.1 → 0.11.6
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/Appraisals +1 -1
- data/Rakefile +1 -1
- data/gemfiles/dry_validation_v1.gemfile +1 -1
- data/glia-errors.gemspec +1 -1
- data/lib/glia/errors/client_errors.rb +69 -2
- data/lib/glia/errors/error_types.rb +8 -1
- data/lib/glia/errors/mapper.rb +2 -1
- data/lib/glia/errors/naming.rb +2 -2
- data/lib/glia/errors.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18b0771e4477d3bad79df4926e73e03178e12838a40d254ac24738ca208147d0
|
4
|
+
data.tar.gz: 8497c21a809704770feb7ee1c1bf687269a699b9419a49879a2abdab5fcf1396
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1ba73e500036b0b18f240841d3c7fe33267e259954c0b12a61c08d3d511a770e3afa1b0644d972e302b1834a91f98654b3cdf178af11b474df564134de66114
|
7
|
+
data.tar.gz: 88f2d9b04a99d2d48e2faca49cdb830e75704133d1165c696534fe919713833e41577c7945e22d169fb3711b0bfdbffe4b5af725793fab0de34f77dd526a1bda
|
data/Appraisals
CHANGED
data/Rakefile
CHANGED
@@ -25,7 +25,7 @@ task :install_test_deps do
|
|
25
25
|
sh 'bundle exec appraisal install'
|
26
26
|
end
|
27
27
|
|
28
|
-
task test: %i[test_dry_validation_v1
|
28
|
+
task test: %i[test_dry_validation_v1]
|
29
29
|
|
30
30
|
task test_dry_validation_v1: :install_test_deps do
|
31
31
|
sh 'bundle exec appraisal dry_validation_v1 rspec'
|
data/glia-errors.gemspec
CHANGED
@@ -56,6 +56,7 @@ module Glia
|
|
56
56
|
DATE = 'date'
|
57
57
|
TIME = 'time'
|
58
58
|
UUID = 'uuid'
|
59
|
+
URL = 'url'
|
59
60
|
end
|
60
61
|
|
61
62
|
def initialize(field:, format: nil, message: nil)
|
@@ -84,6 +85,8 @@ module Glia
|
|
84
85
|
'ISO-8601 date and time'
|
85
86
|
when Formats::UUID
|
86
87
|
'UUID'
|
88
|
+
when Formats::URL
|
89
|
+
'URL'
|
87
90
|
else
|
88
91
|
raise 'Unexpected InvalidFormatError format'
|
89
92
|
end
|
@@ -184,14 +187,27 @@ module Glia
|
|
184
187
|
Naming.assert_snake_case(resource)
|
185
188
|
|
186
189
|
super(
|
187
|
-
type:
|
188
|
-
ref: create_ref(
|
190
|
+
type: RESOURCE_LIMIT_EXCEEDED_ERROR,
|
191
|
+
ref: create_ref(RESOURCE_LIMIT_EXCEEDED_ERROR),
|
189
192
|
message: message || "#{Naming.humanize(resource)} count must not exceed #{max}",
|
190
193
|
error_details: { resource: resource, max: max }
|
191
194
|
)
|
192
195
|
end
|
193
196
|
end
|
194
197
|
|
198
|
+
class ResourceMinimumNotReachedError < Error
|
199
|
+
def initialize(resource:, min:, message: nil)
|
200
|
+
Naming.assert_snake_case(resource)
|
201
|
+
|
202
|
+
super(
|
203
|
+
type: RESOURCE_MINIMUM_NOT_REACHED,
|
204
|
+
ref: create_ref(RESOURCE_MINIMUM_NOT_REACHED),
|
205
|
+
message: message || "#{Naming.humanize(resource)} count must reach at least #{min}",
|
206
|
+
error_details: { resource: resource, min: min }
|
207
|
+
)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
195
211
|
class ResourceAlreadyExistsError < Error
|
196
212
|
def initialize(resource:, message: nil)
|
197
213
|
Naming.assert_snake_case(resource)
|
@@ -347,6 +363,57 @@ module Glia
|
|
347
363
|
)
|
348
364
|
end
|
349
365
|
end
|
366
|
+
|
367
|
+
class FacebookAccessTokenPermissionsError < Error
|
368
|
+
def initialize(message: nil)
|
369
|
+
super(
|
370
|
+
type: FACEBOOK_ACCESS_TOKEN_PERMISSIONS_ERROR,
|
371
|
+
ref: create_ref(FACEBOOK_ACCESS_TOKEN_PERMISSIONS_ERROR),
|
372
|
+
message: message || 'Access token does not have sufficient permissions'
|
373
|
+
)
|
374
|
+
end
|
375
|
+
end
|
376
|
+
|
377
|
+
class FacebookAccessTokenNotPermanentError < Error
|
378
|
+
def initialize(message: nil)
|
379
|
+
super(
|
380
|
+
type: FACEBOOK_ACCESS_TOKEN_NOT_PERMANENT_ERROR,
|
381
|
+
ref: create_ref(FACEBOOK_ACCESS_TOKEN_NOT_PERMANENT_ERROR),
|
382
|
+
message: message || 'Access token does not yield permanent access tokens'
|
383
|
+
)
|
384
|
+
end
|
385
|
+
end
|
386
|
+
|
387
|
+
class OAuthCodeExpiredError < Error
|
388
|
+
def initialize(message: nil)
|
389
|
+
super(
|
390
|
+
type: OAUTH_CODE_EXPIRED_ERROR,
|
391
|
+
ref: create_ref(OAUTH_CODE_EXPIRED_ERROR),
|
392
|
+
message: message || 'OAuth code has expired'
|
393
|
+
)
|
394
|
+
end
|
395
|
+
end
|
396
|
+
|
397
|
+
class OAuthCodeAlreadyUsedError < Error
|
398
|
+
def initialize(message: nil)
|
399
|
+
super(
|
400
|
+
type: OAUTH_CODE_ALREADY_USED_ERROR,
|
401
|
+
ref: create_ref(OAUTH_CODE_ALREADY_USED_ERROR),
|
402
|
+
message: message || 'OAuth code has already been used'
|
403
|
+
)
|
404
|
+
end
|
405
|
+
end
|
406
|
+
|
407
|
+
class AppleBusinessChatBusinessUsedByOtherSiteError < Error
|
408
|
+
def initialize(message: nil)
|
409
|
+
super(
|
410
|
+
type: APPLE_BUSINESS_CHAT_BUSINESS_USED_BY_OTHER_SITE_ERROR,
|
411
|
+
ref: create_ref(APPLE_BUSINESS_CHAT_BUSINESS_USED_BY_OTHER_SITE_ERROR),
|
412
|
+
message: message || 'Business is already used by a channel on another site'
|
413
|
+
)
|
414
|
+
end
|
415
|
+
end
|
416
|
+
|
350
417
|
# rubocop:enable Style/Documentation
|
351
418
|
end
|
352
419
|
end
|
@@ -14,7 +14,8 @@ module Glia
|
|
14
14
|
RESOURCE_NOT_FOUND_ERROR = 'resource_not_found_error'
|
15
15
|
NOT_VERIFIED_ERROR = 'not_verified_error'
|
16
16
|
REMAINING_ASSOCIATION_ERROR = 'remaining_association_error'
|
17
|
-
|
17
|
+
RESOURCE_LIMIT_EXCEEDED_ERROR = 'resource_limit_exceeded_error'
|
18
|
+
RESOURCE_MINIMUM_NOT_REACHED = 'resource_minimum_not_reached'
|
18
19
|
RESOURCE_ALREADY_EXISTS_ERROR = 'resource_already_exists_error'
|
19
20
|
INVALID_RESOURCE_STATE_ERROR = 'invalid_resource_state_error'
|
20
21
|
AUTHORIZATION_ERROR = 'authorization_error'
|
@@ -29,6 +30,12 @@ module Glia
|
|
29
30
|
TWILIO_MESSAGING_SERVICE_CONFIGURATION_ERROR = 'twilio_messaging_service_configuration_error'
|
30
31
|
UNREACHABLE_DESTINATION_ERROR = 'unreachable_destination_error'
|
31
32
|
HEADERS_VALIDATION_ERROR = 'headers_validation_error'
|
33
|
+
FACEBOOK_ACCESS_TOKEN_PERMISSIONS_ERROR = 'facebook_access_token_permissions_error'
|
34
|
+
FACEBOOK_ACCESS_TOKEN_NOT_PERMANENT_ERROR = 'facebook_access_token_not_permanent_error'
|
35
|
+
OAUTH_CODE_EXPIRED_ERROR = 'oauth_code_expired_error'
|
36
|
+
OAUTH_CODE_ALREADY_USED_ERROR = 'oauth_code_already_used_error'
|
37
|
+
APPLE_BUSINESS_CHAT_BUSINESS_USED_BY_OTHER_SITE_ERROR =
|
38
|
+
'apple_business_chat_business_used_by_other_site_error'
|
32
39
|
|
33
40
|
# Server errors
|
34
41
|
INTERNAL_SERVER_ERROR = 'internal_server_error'
|
data/lib/glia/errors/mapper.rb
CHANGED
@@ -125,7 +125,8 @@ module Glia
|
|
125
125
|
'is missing' => MISSING_VALUE_ERROR,
|
126
126
|
# Custom format errors
|
127
127
|
'must be in E.164 format' => INVALID_FORMAT_ERROR,
|
128
|
-
'must be up to 7
|
128
|
+
'must be up to 25 symbol string that contains only 1-7 digits and commas' =>
|
129
|
+
INVALID_FORMAT_ERROR,
|
129
130
|
'must be a valid email' => INVALID_FORMAT_ERROR
|
130
131
|
}.freeze
|
131
132
|
|
data/lib/glia/errors/naming.rb
CHANGED
@@ -13,8 +13,8 @@ module Glia
|
|
13
13
|
upcase_first(result)
|
14
14
|
end
|
15
15
|
|
16
|
-
ABBREVIATIONS = %w[id uuid saml sip sms mms].freeze
|
17
|
-
PLURAL_ABBREVIATIONS = %w[ids uuids].freeze
|
16
|
+
ABBREVIATIONS = %w[id uuid saml sip sms mms uri url].freeze
|
17
|
+
PLURAL_ABBREVIATIONS = %w[ids uuids uris urls].freeze
|
18
18
|
|
19
19
|
private_class_method def self.upcase_if_abbreviation(value)
|
20
20
|
if ABBREVIATIONS.include?(value)
|
data/lib/glia/errors.rb
CHANGED
@@ -12,7 +12,7 @@ module Glia
|
|
12
12
|
def self.from_dry_validation_result(result, custom_error_map = {})
|
13
13
|
dry_validation_version = Gem.loaded_specs['dry-validation'].version
|
14
14
|
if dry_validation_version < Gem::Version.new('1.0')
|
15
|
-
Mapper.from_dry_validation_result(result.output, result.
|
15
|
+
Mapper.from_dry_validation_result(result.output, result.errors, custom_error_map)
|
16
16
|
elsif dry_validation_version <= Gem::Version.new('1.6')
|
17
17
|
Mapper.from_dry_validation_result(result.to_h, result.errors.to_h, custom_error_map)
|
18
18
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glia-errors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Glia TechMovers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: ''
|
14
14
|
email:
|