glia-errors 0.15.0 → 0.15.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ae72fe1322934f08cc64c13b2e9ad1d826e327a3efac260e14b2b0da26ad66a5
4
- data.tar.gz: 6a9bc75c7e7f552edd739741ed636b048d7994442ba9d3885f5429ee4fc16a6f
3
+ metadata.gz: 48f6a6310b82d72e3d0a635c38839b494fc61dc48157ad1373ae02f2c6615d50
4
+ data.tar.gz: 10b23d6c1b11dfb98e238a8bb61a52dbec239aaafa632b030e3f0f766428d46c
5
5
  SHA512:
6
- metadata.gz: ac2f2a450f442b6261bbbe7034ae2e8e4556261195a0fbae20e8cbe0d5a85035957005528c0aad23ab1ccd046d68a453a255ce0619d5a903e10c9a13efacf48e
7
- data.tar.gz: 16e41309e3a229581f5bea5f1f25d7419123d4a25ce44ca5605e6a169eeae09175cf638074e44d6753240cceb670df2c926d13e10b72022bd4eb8c9032c0b2f3
6
+ metadata.gz: 1d4fdd3e92aa7813263b8bdc127f98de09039d0ad6fb0de0115e623ce47025b341ad7717ce94f18b4e03baea4d785dc3214f18cb24221b1c4dc6aad884c1bb54
7
+ data.tar.gz: f340b151ad28ea9c896f97dfc9139672ce145fd2a031b8c809d6920f616d561e4bb88574ccabeb139f33e27ad661ea88929c3c9533a79306ffc0bff26fc31a99
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- glia-errors (0.15.0)
4
+ glia-errors (0.15.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/glia-errors.gemspec CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'glia-errors'
8
- spec.version = '0.15.0'
8
+ spec.version = '0.15.2'
9
9
  spec.authors = ['Glia TechMovers']
10
10
  spec.email = ['techmovers@glia.com']
11
11
 
@@ -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'
@@ -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
@@ -14,8 +14,13 @@ module Glia
14
14
  end
15
15
 
16
16
  class BadGatewayError < Error
17
- def initialize(message: nil)
18
- super(type: BAD_GATEWAY_ERROR, ref: create_ref(BAD_GATEWAY_ERROR), message: message || 'Bad Gateway')
17
+ def initialize(message: nil, error_details: nil)
18
+ super(
19
+ type: BAD_GATEWAY_ERROR,
20
+ ref: create_ref(BAD_GATEWAY_ERROR),
21
+ message: message || 'Bad Gateway',
22
+ error_details: error_details
23
+ )
19
24
  end
20
25
  end
21
26
 
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.0
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-10-25 00:00:00.000000000 Z
11
+ date: 2023-11-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: ''
14
14
  email: