glia-errors 0.11.10 → 0.11.11
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/.prettierrc +1 -1
- data/Appraisals +1 -0
- data/README.md +5 -0
- data/gemfiles/dry_validation_v0.gemfile +1 -0
- data/glia-errors.gemspec +1 -1
- data/lib/glia/errors/client_errors.rb +22 -11
- data/lib/glia/errors/error.rb +3 -8
- data/lib/glia/errors/error_types.rb +2 -2
- data/lib/glia/errors/mapper.rb +4 -12
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 171865a0d5dbbd2469f022baecf691da4593a50765bbd6032b64641316208d93
|
4
|
+
data.tar.gz: 4f5520230499c9cdb90ec3276c6092408b04f3d9b3a3574d72100504f6d0d653
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a86c2deacb6b53bb3af9701fd2eebe946a11537560dca47230c0b521653e162bf5d452a1d245a8d6d7c12b98a1ebe6d0e290a6de324841d3f476242542b180b3
|
7
|
+
data.tar.gz: cfde2dbd2c1cc7c973c3b9c335dc536e314619844835abe199b2c49f3e1ef6361185ef5bbca7a05ef3e4fe8899df62be08f2d0d7492de66b518d1db11c2c3482
|
data/.prettierrc
CHANGED
@@ -1 +1 @@
|
|
1
|
-
printWidth:
|
1
|
+
printWidth: 120
|
data/Appraisals
CHANGED
data/README.md
CHANGED
@@ -106,6 +106,11 @@ else
|
|
106
106
|
end
|
107
107
|
```
|
108
108
|
|
109
|
+
## Releasing a new version
|
110
|
+
|
111
|
+
A new version is created when a change is merged into the master branch that changes the version number in `glia-errors.gemspec`.
|
112
|
+
A Github Action will push the `.gem` file to [rubygems.org](https://rubygems.org)
|
113
|
+
|
109
114
|
## Contributing
|
110
115
|
|
111
116
|
### Testing
|
data/glia-errors.gemspec
CHANGED
@@ -62,11 +62,7 @@ module Glia
|
|
62
62
|
|
63
63
|
def initialize(field:, format: nil, message: nil)
|
64
64
|
default_message =
|
65
|
-
|
66
|
-
"has invalid format, required format is #{humanize_format(format)}"
|
67
|
-
else
|
68
|
-
'has invalid format'
|
69
|
-
end
|
65
|
+
format ? "has invalid format, required format is #{humanize_format(format)}" : 'has invalid format'
|
70
66
|
super(
|
71
67
|
type: INVALID_FORMAT_ERROR,
|
72
68
|
ref: create_ref(INVALID_FORMAT_ERROR),
|
@@ -261,9 +257,7 @@ module Glia
|
|
261
257
|
class RouteNotFoundError < Error
|
262
258
|
def initialize(message: nil)
|
263
259
|
super(
|
264
|
-
type: ROUTE_NOT_FOUND_ERROR,
|
265
|
-
ref: create_ref(ROUTE_NOT_FOUND_ERROR),
|
266
|
-
message: message || 'Route not found'
|
260
|
+
type: ROUTE_NOT_FOUND_ERROR, ref: create_ref(ROUTE_NOT_FOUND_ERROR), message: message || 'Route not found'
|
267
261
|
)
|
268
262
|
end
|
269
263
|
end
|
@@ -281,9 +275,7 @@ module Glia
|
|
281
275
|
class CarrierError < Error
|
282
276
|
def initialize(message: nil)
|
283
277
|
super(
|
284
|
-
type: CARRIER_ERROR,
|
285
|
-
ref: create_ref(CARRIER_ERROR),
|
286
|
-
message: message || 'Downstream carrier issue occurred'
|
278
|
+
type: CARRIER_ERROR, ref: create_ref(CARRIER_ERROR), message: message || 'Downstream carrier issue occurred'
|
287
279
|
)
|
288
280
|
end
|
289
281
|
end
|
@@ -417,6 +409,25 @@ module Glia
|
|
417
409
|
end
|
418
410
|
end
|
419
411
|
|
412
|
+
class ItemsOverlapError < Error
|
413
|
+
def initialize(overlapping_item_indexes:, message: nil)
|
414
|
+
raise ArgumentError, 'overlapping_item_indexes value must be list' unless overlapping_item_indexes.is_a?(Array)
|
415
|
+
|
416
|
+
raise ArgumentError, 'at least 2 overlapping item indexes are required' if overlapping_item_indexes.size < 2
|
417
|
+
|
418
|
+
overlapping_item_indexes.each do |value|
|
419
|
+
raise ArgumentError, 'overlapping_item_indexes values must be integers' unless value.is_a?(Integer)
|
420
|
+
end
|
421
|
+
|
422
|
+
super(
|
423
|
+
type: ITEMS_OVERLAP_ERROR,
|
424
|
+
ref: create_ref(ITEMS_OVERLAP_ERROR),
|
425
|
+
message: message || 'Items must not overlap each other',
|
426
|
+
error_details: { overlapping_item_indexes: overlapping_item_indexes }
|
427
|
+
)
|
428
|
+
end
|
429
|
+
end
|
430
|
+
|
420
431
|
# rubocop:enable Style/Documentation
|
421
432
|
end
|
422
433
|
end
|
data/lib/glia/errors/error.rb
CHANGED
@@ -16,9 +16,7 @@ module Glia
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def to_h
|
19
|
-
{
|
20
|
-
type: type, ref: ref, message: message, error_details: error_details_to_h(@error_details)
|
21
|
-
}.compact
|
19
|
+
{ type: type, ref: ref, message: message, error_details: error_details_to_h(@error_details) }.compact
|
22
20
|
end
|
23
21
|
|
24
22
|
private
|
@@ -27,9 +25,7 @@ module Glia
|
|
27
25
|
return details if primitive?(details)
|
28
26
|
|
29
27
|
if details.is_a?(Hash)
|
30
|
-
details.keys.each_with_object({})
|
31
|
-
hash[field] = error_details_to_h(details[field])
|
32
|
-
end
|
28
|
+
details.keys.each_with_object({}) { |field, hash| hash[field] = error_details_to_h(details[field]) }
|
33
29
|
elsif details.is_a?(Array)
|
34
30
|
details.map { |error| error_details_to_h(error) }
|
35
31
|
elsif details.respond_to?(:to_h)
|
@@ -40,8 +36,7 @@ module Glia
|
|
40
36
|
end
|
41
37
|
|
42
38
|
def primitive?(details)
|
43
|
-
details.nil? ||
|
44
|
-
[TrueClass, FalseClass, String, Integer, Float, Symbol].include?(details.class)
|
39
|
+
details.nil? || [TrueClass, FalseClass, String, Integer, Float, Symbol].include?(details.class)
|
45
40
|
end
|
46
41
|
|
47
42
|
def create_ref(type)
|
@@ -34,8 +34,8 @@ module Glia
|
|
34
34
|
FACEBOOK_ACCESS_TOKEN_NOT_PERMANENT_ERROR = 'facebook_access_token_not_permanent_error'
|
35
35
|
OAUTH_CODE_EXPIRED_ERROR = 'oauth_code_expired_error'
|
36
36
|
OAUTH_CODE_ALREADY_USED_ERROR = 'oauth_code_already_used_error'
|
37
|
-
APPLE_BUSINESS_CHAT_BUSINESS_USED_BY_OTHER_SITE_ERROR =
|
38
|
-
|
37
|
+
APPLE_BUSINESS_CHAT_BUSINESS_USED_BY_OTHER_SITE_ERROR = 'apple_business_chat_business_used_by_other_site_error'
|
38
|
+
ITEMS_OVERLAP_ERROR = 'items_overlap_error'
|
39
39
|
|
40
40
|
# Server errors
|
41
41
|
INTERNAL_SERVER_ERROR = 'internal_server_error'
|
data/lib/glia/errors/mapper.rb
CHANGED
@@ -12,8 +12,7 @@ module Glia
|
|
12
12
|
InvalidTypeError::Types::ARRAY
|
13
13
|
when 'must be an integer', 'must be Integer'
|
14
14
|
InvalidTypeError::Types::INTEGER
|
15
|
-
when 'must be a number', 'must be a float', 'must be a decimal', 'must be Float',
|
16
|
-
'must be BigDecimal'
|
15
|
+
when 'must be a number', 'must be a float', 'must be a decimal', 'must be Float', 'must be BigDecimal'
|
17
16
|
InvalidTypeError::Types::NUMBER
|
18
17
|
when 'must be a hash', 'must be Hash'
|
19
18
|
InvalidTypeError::Types::OBJECT
|
@@ -39,11 +38,7 @@ module Glia
|
|
39
38
|
# so we are separating them ourselves
|
40
39
|
INVALID_NUMBER_OR_VALUE_ERROR =
|
41
40
|
lambda do |field, value, _message|
|
42
|
-
|
43
|
-
InvalidValueError.new(field: field)
|
44
|
-
else
|
45
|
-
InvalidNumberError.new(field: field)
|
46
|
-
end
|
41
|
+
value.is_a?(String) ? InvalidValueError.new(field: field) : InvalidNumberError.new(field: field)
|
47
42
|
end
|
48
43
|
|
49
44
|
INVALID_DATE_FORMAT =
|
@@ -125,8 +120,7 @@ module Glia
|
|
125
120
|
'is missing' => MISSING_VALUE_ERROR,
|
126
121
|
# Custom format errors
|
127
122
|
'must be in E.164 format' => INVALID_FORMAT_ERROR,
|
128
|
-
'must be up to 25 symbol string that contains only 1-7 digits and commas' =>
|
129
|
-
INVALID_FORMAT_ERROR,
|
123
|
+
'must be up to 25 symbol string that contains only 1-7 digits and commas' => INVALID_FORMAT_ERROR,
|
130
124
|
'must be a valid email' => INVALID_FORMAT_ERROR
|
131
125
|
}.freeze
|
132
126
|
|
@@ -146,9 +140,7 @@ module Glia
|
|
146
140
|
# This is not needed for the `else` case as dry-validation already provides an array.
|
147
141
|
[from_dry_validation_result_rec(field_value, field_messages, error_map)]
|
148
142
|
else
|
149
|
-
field_messages.map
|
150
|
-
from_dry_validation_error(field, field_value, message, error_map)
|
151
|
-
end
|
143
|
+
field_messages.map { |message| from_dry_validation_error(field, field_value, message, error_map) }
|
152
144
|
end
|
153
145
|
end
|
154
146
|
InputValidationError.new(error_details: error_details)
|
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.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Glia TechMovers
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: ''
|
14
14
|
email:
|
@@ -39,11 +39,11 @@ files:
|
|
39
39
|
- lib/glia/errors/mapper.rb
|
40
40
|
- lib/glia/errors/naming.rb
|
41
41
|
- lib/glia/errors/server_errors.rb
|
42
|
-
homepage:
|
42
|
+
homepage:
|
43
43
|
licenses:
|
44
44
|
- MIT
|
45
45
|
metadata: {}
|
46
|
-
post_install_message:
|
46
|
+
post_install_message:
|
47
47
|
rdoc_options: []
|
48
48
|
require_paths:
|
49
49
|
- lib
|
@@ -61,8 +61,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
requirements: []
|
64
|
-
rubygems_version: 3.
|
65
|
-
signing_key:
|
64
|
+
rubygems_version: 3.1.2
|
65
|
+
signing_key:
|
66
66
|
specification_version: 4
|
67
67
|
summary: Glia REST API errors
|
68
68
|
test_files: []
|