glia-errors 0.15.1 → 0.15.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/glia-errors.gemspec +1 -1
- data/lib/glia/errors/client_errors.rb +18 -1
- data/lib/glia/errors/error_types.rb +1 -0
- data/lib/glia/errors/naming.rb +2 -2
- 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: 48f6a6310b82d72e3d0a635c38839b494fc61dc48157ad1373ae02f2c6615d50
|
4
|
+
data.tar.gz: 10b23d6c1b11dfb98e238a8bb61a52dbec239aaafa632b030e3f0f766428d46c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d4fdd3e92aa7813263b8bdc127f98de09039d0ad6fb0de0115e623ce47025b341ad7717ce94f18b4e03baea4d785dc3214f18cb24221b1c4dc6aad884c1bb54
|
7
|
+
data.tar.gz: f340b151ad28ea9c896f97dfc9139672ce145fd2a031b8c809d6920f616d561e4bb88574ccabeb139f33e27ad661ea88929c3c9533a79306ffc0bff26fc31a99
|
data/Gemfile.lock
CHANGED
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(
|
@@ -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'
|
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.15.
|
4
|
+
version: 0.15.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Glia TechMovers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: ''
|
14
14
|
email:
|