glia-errors 0.15.1 → 0.16.0
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/.rubocop.yml +15 -0
- data/Gemfile +0 -1
- data/Gemfile.lock +1 -3
- data/README.md +2 -2
- data/Rakefile +1 -9
- data/glia-errors.gemspec +1 -1
- data/lib/glia/errors/client_errors.rb +28 -1
- data/lib/glia/errors/error_types.rb +2 -0
- data/lib/glia/errors/naming.rb +2 -2
- metadata +7 -9
- data/.prettierignore +0 -2
- data/.prettierrc +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a06054cd6b58ba940ed3f0b4cc9451b96d6f50ce4acc3cd30e85ab6c3465e2d8
|
4
|
+
data.tar.gz: eedb34bf63a25b09cd416dcfc785e3993f81856575a290f411145e9215f5b659
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b8de5872631c896cea9a1eea80a3043fc1314bcebf2725da8674efd34c08e56241fef4fc21232526b8a97e9007031b32e39c12c14b7aae9fed18c2466be8182
|
7
|
+
data.tar.gz: 2eb2037a90bd268120d96ff0acb56c22bfb2a48bef6bc7e5991572c41b77302373ea80921a9220d808d38a96cd9e30230f0a708b9ecdc21cbe4489de82528759
|
data/.rubocop.yml
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rspec
|
3
|
+
|
1
4
|
AllCops:
|
2
5
|
TargetRubyVersion: 2.5
|
3
6
|
NewCops: enable
|
@@ -15,5 +18,17 @@ Metrics/BlockLength:
|
|
15
18
|
Exclude:
|
16
19
|
- 'spec/**/*'
|
17
20
|
|
21
|
+
RSpec/DescribeClass:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
RSpec/DescribedClass:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
RSpec/MultipleExpectations:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
RSpec/ExampleLength:
|
31
|
+
Enabled: false
|
32
|
+
|
18
33
|
Gemspec/RequireMFA:
|
19
34
|
Enabled: false
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
glia-errors (0.15.
|
4
|
+
glia-errors (0.15.2)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -48,7 +48,6 @@ GEM
|
|
48
48
|
ast (~> 2.4.1)
|
49
49
|
patience_diff (1.2.0)
|
50
50
|
optimist (~> 3.0)
|
51
|
-
prettier (0.22.0)
|
52
51
|
rainbow (3.1.1)
|
53
52
|
rake (13.0.1)
|
54
53
|
regexp_parser (2.2.1)
|
@@ -96,7 +95,6 @@ PLATFORMS
|
|
96
95
|
DEPENDENCIES
|
97
96
|
dry-validation (~> 1.10)
|
98
97
|
glia-errors!
|
99
|
-
prettier (~> 0.22)
|
100
98
|
rake (~> 13.0)
|
101
99
|
rspec (~> 3.10)
|
102
100
|
rubocop (~> 1.5)
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -11,12 +11,4 @@ RuboCop::RakeTask.new do |task|
|
|
11
11
|
task.requires << 'rubocop-rspec'
|
12
12
|
end
|
13
13
|
|
14
|
-
task default: %i[
|
15
|
-
|
16
|
-
task :lint do
|
17
|
-
sh "rubocop && rbprettier --check '**/*.rb'"
|
18
|
-
end
|
19
|
-
|
20
|
-
task :format do
|
21
|
-
sh "rbprettier --write '**/*.rb'"
|
22
|
-
end
|
14
|
+
task default: %i[rubocop spec]
|
data/glia-errors.gemspec
CHANGED
@@ -170,7 +170,7 @@ module Glia
|
|
170
170
|
|
171
171
|
default_message =
|
172
172
|
"cannot be modified/deleted because it is associated to one or more #{
|
173
|
-
Naming.humanize(associated_resource)
|
173
|
+
Naming.humanize(associated_resource, lowercase: true)
|
174
174
|
}(s)"
|
175
175
|
super(
|
176
176
|
type: REMAINING_ASSOCIATION_ERROR,
|
@@ -248,6 +248,23 @@ module Glia
|
|
248
248
|
end
|
249
249
|
end
|
250
250
|
|
251
|
+
class ChangingFieldNotAllowedError < Error
|
252
|
+
def initialize(resource:, field:, message: nil)
|
253
|
+
Naming.assert_snake_case(resource)
|
254
|
+
Naming.assert_snake_case(field)
|
255
|
+
|
256
|
+
default_message =
|
257
|
+
"Once value of `#{field}` is set for the #{Naming.humanize(resource, lowercase: true)}, it cannot be changed"
|
258
|
+
|
259
|
+
super(
|
260
|
+
type: CHANGING_FIELD_NOT_ALLOWED_ERROR,
|
261
|
+
ref: create_ref(CHANGING_FIELD_NOT_ALLOWED_ERROR),
|
262
|
+
message: message || default_message,
|
263
|
+
error_details: { resource: resource, field: field }
|
264
|
+
)
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
251
268
|
class AuthorizationError < Error
|
252
269
|
def initialize(message: nil)
|
253
270
|
super(
|
@@ -472,6 +489,16 @@ module Glia
|
|
472
489
|
end
|
473
490
|
end
|
474
491
|
|
492
|
+
class NoMatchingRoutingRuleError < Error
|
493
|
+
def initialize(message: nil)
|
494
|
+
super(
|
495
|
+
type: NO_MATCHING_ROUTING_RULE_ERROR,
|
496
|
+
ref: create_ref(NO_MATCHING_ROUTING_RULE_ERROR),
|
497
|
+
message: message || 'Matching routing rule not found'
|
498
|
+
)
|
499
|
+
end
|
500
|
+
end
|
501
|
+
|
475
502
|
# rubocop:enable Style/Documentation
|
476
503
|
end
|
477
504
|
end
|
@@ -19,6 +19,7 @@ module Glia
|
|
19
19
|
RESOURCE_LOCKED = 'resource_locked'
|
20
20
|
RESOURCE_ALREADY_EXISTS_ERROR = 'resource_already_exists_error'
|
21
21
|
INVALID_RESOURCE_STATE_ERROR = 'invalid_resource_state_error'
|
22
|
+
CHANGING_FIELD_NOT_ALLOWED_ERROR = 'changing_field_not_allowed_error'
|
22
23
|
AUTHORIZATION_ERROR = 'authorization_error'
|
23
24
|
RECIPIENT_OPTED_OUT_ERROR = 'recipient_opted_out_error'
|
24
25
|
ROUTE_NOT_FOUND_ERROR = 'route_not_found_error'
|
@@ -40,6 +41,7 @@ module Glia
|
|
40
41
|
FEATURE_DISABLED_ERROR = 'feature_disabled_error'
|
41
42
|
UNSUPPORTED_MEDIA_TYPE_ERROR = 'unsupported_media_type'
|
42
43
|
TOO_MANY_REQUESTS_ERROR = 'too_many_requests'
|
44
|
+
NO_MATCHING_ROUTING_RULE_ERROR = 'no_matching_routing_rule_error'
|
43
45
|
|
44
46
|
# Server errors
|
45
47
|
INTERNAL_SERVER_ERROR = 'internal_server_error'
|
data/lib/glia/errors/naming.rb
CHANGED
@@ -7,10 +7,10 @@ module Glia
|
|
7
7
|
# Converts from camel_case to more human readable value
|
8
8
|
# first_name => "First name"
|
9
9
|
# site_id => "Site ID"
|
10
|
-
def self.humanize(value)
|
10
|
+
def self.humanize(value, lowercase: false)
|
11
11
|
result = value.to_s.split('_').map { |word| upcase_if_abbreviation(word) }.join(' ')
|
12
12
|
|
13
|
-
upcase_first(result)
|
13
|
+
lowercase ? result : upcase_first(result)
|
14
14
|
end
|
15
15
|
|
16
16
|
ABBREVIATIONS = %w[id uuid saml sip sms mms uri url].freeze
|
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.16.0
|
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:
|
11
|
+
date: 2025-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: ''
|
14
14
|
email:
|
@@ -18,8 +18,6 @@ extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
20
|
- ".gitignore"
|
21
|
-
- ".prettierignore"
|
22
|
-
- ".prettierrc"
|
23
21
|
- ".rspec"
|
24
22
|
- ".rubocop.yml"
|
25
23
|
- ".ruby-version"
|
@@ -36,11 +34,11 @@ files:
|
|
36
34
|
- lib/glia/errors/mapper.rb
|
37
35
|
- lib/glia/errors/naming.rb
|
38
36
|
- lib/glia/errors/server_errors.rb
|
39
|
-
homepage:
|
37
|
+
homepage:
|
40
38
|
licenses:
|
41
39
|
- MIT
|
42
40
|
metadata: {}
|
43
|
-
post_install_message:
|
41
|
+
post_install_message:
|
44
42
|
rdoc_options: []
|
45
43
|
require_paths:
|
46
44
|
- lib
|
@@ -58,8 +56,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
56
|
- !ruby/object:Gem::Version
|
59
57
|
version: '0'
|
60
58
|
requirements: []
|
61
|
-
rubygems_version: 3.
|
62
|
-
signing_key:
|
59
|
+
rubygems_version: 3.4.20
|
60
|
+
signing_key:
|
63
61
|
specification_version: 4
|
64
62
|
summary: Glia REST API errors
|
65
63
|
test_files: []
|
data/.prettierignore
DELETED
data/.prettierrc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
printWidth: 120
|