glia-errors 0.11.0 → 0.11.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Appraisals +2 -1
- data/README.md +1 -1
- data/gemfiles/dry_validation_v0.gemfile +1 -0
- 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: d71a904099bb9ddc69b22b6f8781ec5f73d30f15db34a117f92b0dde9700b2e3
|
4
|
+
data.tar.gz: 58dab077b61ebf6143d38afdcc3a8468a3ccdfe57586a099bf26633482d93526
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a8c8fc492018dbc59f262b3068c7e81b42a88b477e67698f52c8b70e35543ca73fa4281d721cecabaeda2084f7749157a33ce3e24ce97d28fa887dc0c210779
|
7
|
+
data.tar.gz: 72ce9907b06c59e05d5920a18bf00920dfca7ef49145509f949adf3bed8190a303896e7901b31dca542d64bd36efeefd041dcc8c00bb86a5cf1bc5ed91e3cbf9
|
data/Appraisals
CHANGED
data/README.md
CHANGED
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
@@ -13,7 +13,7 @@ module Glia
|
|
13
13
|
dry_validation_version = Gem.loaded_specs['dry-validation'].version
|
14
14
|
if dry_validation_version < Gem::Version.new('1.0')
|
15
15
|
Mapper.from_dry_validation_result(result.output, result.errors, custom_error_map)
|
16
|
-
elsif dry_validation_version <= Gem::Version.new('1.
|
16
|
+
elsif dry_validation_version <= Gem::Version.new('1.7')
|
17
17
|
Mapper.from_dry_validation_result(result.to_h, result.errors.to_h, custom_error_map)
|
18
18
|
else
|
19
19
|
raise 'Unsupported dry-validation version'
|
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.11.
|
4
|
+
version: 0.11.7
|
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-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: ''
|
14
14
|
email:
|