glia-errors 0.14.0 → 0.15.0

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: c54253c9c31cff619c7be5f0519497d16e4fbffd7d99b028342d5a8c09afdea1
4
- data.tar.gz: 2cd269d97b594a3b1c5a0bb629ace07919f2820e1e33919f9d1128b0a4a9d089
3
+ metadata.gz: ae72fe1322934f08cc64c13b2e9ad1d826e327a3efac260e14b2b0da26ad66a5
4
+ data.tar.gz: 6a9bc75c7e7f552edd739741ed636b048d7994442ba9d3885f5429ee4fc16a6f
5
5
  SHA512:
6
- metadata.gz: 9e0cd589a2f4a609a8d412327134d6287e952aca20c000c6b41b5a7f5413021af543c5193b7040f74096ab3c037cd5b0c5487a47f73180f603aba9d868ef9cc9
7
- data.tar.gz: 6654fd33524e1f7ff0adf13b66b95281df248224465037ab6441e672276fa701affb9cfd9a59a3b6b4bfd3e3116933810e7347bbd80851cccf7d770889c2da08
6
+ metadata.gz: ac2f2a450f442b6261bbbe7034ae2e8e4556261195a0fbae20e8cbe0d5a85035957005528c0aad23ab1ccd046d68a453a255ce0619d5a903e10c9a13efacf48e
7
+ data.tar.gz: 16e41309e3a229581f5bea5f1f25d7419123d4a25ce44ca5605e6a169eeae09175cf638074e44d6753240cceb670df2c926d13e10b72022bd4eb8c9032c0b2f3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- glia-errors (0.14.0)
4
+ glia-errors (0.15.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -114,7 +114,7 @@ A Github Action will push the `.gem` file to [rubygems.org](https://rubygems.org
114
114
  ### Testing
115
115
 
116
116
  ```
117
- bundle exec rake test
117
+ bundle exec rake spec
118
118
  ```
119
119
 
120
120
  ### Formatting
data/catalog-info.yaml ADDED
@@ -0,0 +1,16 @@
1
+ ---
2
+ apiVersion: backstage.io/v1alpha1
3
+ kind: Component
4
+ metadata:
5
+ name: glia-errors-ruby
6
+ description: Implements Glia errors in Ruby and provides utilities to easily construct them.
7
+ annotations:
8
+ github.com/project-slug: salemove/glia-errors
9
+ github.com/team-slug: salemove/tm-movers
10
+ snyk.io/org-name: glia-movers
11
+ tags:
12
+ - ruby
13
+ spec:
14
+ type: library
15
+ lifecycle: production
16
+ owner: tm-messenger
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.14.0'
8
+ spec.version = '0.15.0'
9
9
  spec.authors = ['Glia TechMovers']
10
10
  spec.email = ['techmovers@glia.com']
11
11
 
@@ -207,6 +207,20 @@ module Glia
207
207
  end
208
208
  end
209
209
 
210
+ class ResourceLockedError < Error
211
+ def initialize(resource:, locked_by: nil, message: nil)
212
+ Naming.assert_snake_case(resource)
213
+
214
+ is_locked_by = locked_by.nil? ? '' : "Locked by: #{locked_by}"
215
+ super(
216
+ type: RESOURCE_LOCKED,
217
+ ref: create_ref(RESOURCE_LOCKED),
218
+ message: message || "#{Naming.humanize(resource)} is locked. #{is_locked_by}",
219
+ error_details: { resource: resource, locked_by: locked_by }
220
+ )
221
+ end
222
+ end
223
+
210
224
  class ResourceAlreadyExistsError < Error
211
225
  def initialize(resource:, message: nil)
212
226
  Naming.assert_snake_case(resource)
@@ -428,6 +442,36 @@ module Glia
428
442
  end
429
443
  end
430
444
 
445
+ class FeatureDisabledError < Error
446
+ def initialize(feature:, message: nil)
447
+ super(
448
+ type: FEATURE_DISABLED_ERROR,
449
+ ref: create_ref(FEATURE_DISABLED_ERROR),
450
+ message: message || "#{Naming.humanize(feature)} is disabled"
451
+ )
452
+ end
453
+ end
454
+
455
+ class UnsupportedMediaTypeError < Error
456
+ def initialize(message: nil)
457
+ super(
458
+ type: UNSUPPORTED_MEDIA_TYPE_ERROR,
459
+ ref: create_ref(UNSUPPORTED_MEDIA_TYPE_ERROR),
460
+ message: message || 'Unsupported Media Type'
461
+ )
462
+ end
463
+ end
464
+
465
+ class TooManyRequestsError < Error
466
+ def initialize(message: nil)
467
+ super(
468
+ type: TOO_MANY_REQUESTS_ERROR,
469
+ ref: create_ref(TOO_MANY_REQUESTS_ERROR),
470
+ message: message || 'Too Many Requests'
471
+ )
472
+ end
473
+ end
474
+
431
475
  # rubocop:enable Style/Documentation
432
476
  end
433
477
  end
@@ -16,6 +16,7 @@ module Glia
16
16
  REMAINING_ASSOCIATION_ERROR = 'remaining_association_error'
17
17
  RESOURCE_LIMIT_EXCEEDED_ERROR = 'resource_limit_exceeded_error'
18
18
  RESOURCE_MINIMUM_NOT_REACHED = 'resource_minimum_not_reached'
19
+ RESOURCE_LOCKED = 'resource_locked'
19
20
  RESOURCE_ALREADY_EXISTS_ERROR = 'resource_already_exists_error'
20
21
  INVALID_RESOURCE_STATE_ERROR = 'invalid_resource_state_error'
21
22
  AUTHORIZATION_ERROR = 'authorization_error'
@@ -36,9 +37,14 @@ module Glia
36
37
  OAUTH_CODE_ALREADY_USED_ERROR = 'oauth_code_already_used_error'
37
38
  APPLE_BUSINESS_CHAT_BUSINESS_USED_BY_OTHER_SITE_ERROR = 'apple_business_chat_business_used_by_other_site_error'
38
39
  ITEMS_OVERLAP_ERROR = 'items_overlap_error'
40
+ FEATURE_DISABLED_ERROR = 'feature_disabled_error'
41
+ UNSUPPORTED_MEDIA_TYPE_ERROR = 'unsupported_media_type'
42
+ TOO_MANY_REQUESTS_ERROR = 'too_many_requests'
39
43
 
40
44
  # Server errors
41
45
  INTERNAL_SERVER_ERROR = 'internal_server_error'
42
46
  SERVICE_UNAVAILABLE_ERROR = 'service_unavailable_error'
47
+ BAD_GATEWAY_ERROR = 'bad_gateway_error'
48
+ GATEWAY_TIMEOUT_ERROR = 'gateway_timeout_error'
43
49
  end
44
50
  end
@@ -120,7 +120,7 @@ module Glia
120
120
  'is missing' => MISSING_VALUE_ERROR,
121
121
  # Custom format errors
122
122
  'must be in E.164 format' => INVALID_FORMAT_ERROR,
123
- 'must be up to 25 symbol string that contains 1-7 digits or hashes and any number of commas' =>
123
+ 'must be up to 25 symbol string that contains 1-25 digits or hashes and any number of commas' =>
124
124
  INVALID_FORMAT_ERROR,
125
125
  'must be a valid email' => INVALID_FORMAT_ERROR
126
126
  }.freeze
@@ -13,6 +13,12 @@ module Glia
13
13
  end
14
14
  end
15
15
 
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')
19
+ end
20
+ end
21
+
16
22
  class ServiceUnavailableError < Error
17
23
  def initialize(message: nil)
18
24
  super(
@@ -22,6 +28,15 @@ module Glia
22
28
  )
23
29
  end
24
30
  end
31
+
32
+ class GatewayTimeoutError < Error
33
+ def initialize(message: nil)
34
+ super(
35
+ type: GATEWAY_TIMEOUT_ERROR, ref: create_ref(GATEWAY_TIMEOUT_ERROR), message: message || 'Gateway Timeout'
36
+ )
37
+ end
38
+ end
39
+
25
40
  # rubocop:enable Style/Documentation
26
41
  end
27
42
  end
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.14.0
4
+ version: 0.15.0
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-01-02 00:00:00.000000000 Z
11
+ date: 2023-10-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: ''
14
14
  email:
@@ -23,11 +23,11 @@ files:
23
23
  - ".rspec"
24
24
  - ".rubocop.yml"
25
25
  - ".ruby-version"
26
- - ".travis.yml"
27
26
  - Gemfile
28
27
  - Gemfile.lock
29
28
  - README.md
30
29
  - Rakefile
30
+ - catalog-info.yaml
31
31
  - glia-errors.gemspec
32
32
  - lib/glia/errors.rb
33
33
  - lib/glia/errors/client_errors.rb
data/.travis.yml DELETED
@@ -1,13 +0,0 @@
1
- language: ruby
2
- dist: trusty
3
- rvm:
4
- - 2.5.0
5
- before_install:
6
- - gem install bundler:2.2.0
7
- before_script:
8
- - nvm install 12
9
- - nvm use 12
10
- - bundle
11
- gemfile:
12
- - gemfiles/dry_validation_v1.gemfile
13
- script: bundle exec rake