erratum 4.0.0 → 4.1.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: 97d95100468476620622a7be9cf70e486922fc3f29a8054a5bda626c9859c1e5
4
- data.tar.gz: 46757dc475658d01525ce9e2ec4c9581c907aa3ae7edf5102ebab271a87b22a4
3
+ metadata.gz: 42348e001695f75bef48c2fc53216daeefb1d818c6a7c84e9029d919eddd65ac
4
+ data.tar.gz: 5526924695f72382843eef7bbe142908a3d9b744aabb7377c43aae98803ef937
5
5
  SHA512:
6
- metadata.gz: 0d637d1a2d25d501ccef7c321a3a3d9c27624c4b265a213c53cd20061afae155cce0f87be1772dfdf63125b57a39923b6df4a9e01cbaad8bb6d63310e0ee14c0
7
- data.tar.gz: eb367c1ad645b49498e8ca870c452dd32d58fd04bc2cc65d01b1267a8ddf7bad4b61883f58849bca66c31f85fa964aba338ad53c73df0cc213a91d3d99012941
6
+ metadata.gz: 90d89f579f91eb101c22f088b4356049a7d4d81b39c6ef531bf42ca26f0e184491adf52073398d7238ed82dbc3af2df3a196571d591e35dbbebf386a769cf893
7
+ data.tar.gz: 3e5dd90f3b9288715b4ff42df2649904a7f0f5c604dc73334103885f16df086950d073e2f35d36dbbb4551e8852f7c09526d1929e9ba091c76894f96be9dcede
checksums.yaml.gz.sig CHANGED
Binary file
@@ -10,6 +10,7 @@ module Erratum
10
10
  'ActionController::ParameterMissing' => '::Erratum::Errors::ParameterMissing',
11
11
  'ActionController::UnpermittedParameters' => '::Erratum::Errors::UnpermittedParameters',
12
12
  'ActiveRecord::InvalidForeignKey' => '::Erratum::Errors::InvalidAssociation',
13
+ 'ActiveRecord::NotNullViolation' => '::Erratum::Errors::ResourcePersistence',
13
14
  'ActiveRecord::RecordInvalid' => '::Erratum::Errors::ResourcePersistence',
14
15
  'ActiveRecord::RecordNotFound' => '::Erratum::Errors::ResourceNotFound',
15
16
  'ActiveRecord::RecordNotSaved' => '::Erratum::Errors::ResourcePersistence',
@@ -12,6 +12,28 @@ class ResourcePersistence < RuntimeError
12
12
  include Error
13
13
  include Errors::Crud
14
14
 
15
+ NOT_NULL_ERROR_MESSAGE_PATTERN = \
16
+ /
17
+ \A # Start Of String
18
+ (?<wrapped_error_class>
19
+ .*? # Followed By Any Text
20
+ )
21
+ :\s # Divider Between Class And Details
22
+ ERROR:\s+ # Literal "ERROR: "
23
+ null\svalue\sin\scolumn\s" # Literal Text
24
+ (?<attribute_name>.*?) # Attribute Name
25
+ "\sof\srelation\s" # Literal Text
26
+ (?<table_name>.*?) # Table Name
27
+ "\sviolates\snot-null\sconstraint # Literal Text
28
+ \n # Newline
29
+ DETAIL:\s+ # Literal Text
30
+ Failing\srow\scontains\s\( # Literal Text
31
+ (?<bindings>.*)
32
+ \)\. # Literal Text
33
+ \n # Newline
34
+ \z # End Of String
35
+ /x
36
+
15
37
  attr_accessor :pointer,
16
38
  :attribute,
17
39
  :value
@@ -43,6 +65,20 @@ class ResourcePersistence < RuntimeError
43
65
 
44
66
  errors << new(**initialization_parameters.merge(overrides))
45
67
  end
68
+ when 'ActiveRecord::NotNullViolation'
69
+ message_details = original_error
70
+ .message
71
+ .match(NOT_NULL_ERROR_MESSAGE_PATTERN)
72
+ .named_captures
73
+
74
+ [
75
+ new(
76
+ attribute: message_details['attribute_name'],
77
+ detail: "#{original_error.class.name}: #{message_details['table_name'].humanize}' #{message_details['attribute_name'].humanize} cannot be null.",
78
+ pointer: "/data/attributes/#{message_details['attribute_name']}",
79
+ value: nil,
80
+ ),
81
+ ]
46
82
  end
47
83
  end
48
84
 
@@ -7,14 +7,15 @@ module RescuableResource
7
7
  def self.included(base) # rubocop:disable Metrics/AbcSize
8
8
  base.include ::AppleCore::ActionController::ResourceNaming
9
9
 
10
- base.rescue_from 'ActiveRecord::RecordInvalid',
11
- 'ActiveRecord::RecordNotSaved',
10
+ base.rescue_from 'ActionController::ParameterMissing',
11
+ 'ActionController::UnpermittedParameters',
12
+ 'ActiveRecord::InvalidForeignKey',
13
+ 'ActiveRecord::NotNullViolation',
14
+ 'ActiveRecord::RecordInvalid',
12
15
  'ActiveRecord::RecordNotFound',
16
+ 'ActiveRecord::RecordNotSaved',
13
17
  'ActiveRecord::RecordNotUnique',
14
- 'ActiveRecord::InvalidForeignKey',
15
- 'ActiveRecord::ValueTooLong',
16
- 'ActionController::ParameterMissing',
17
- 'ActionController::UnpermittedParameters' do |exception|
18
+ 'ActiveRecord::ValueTooLong' do |exception|
18
19
  erratum = Array(
19
20
  Erratum.build(
20
21
  exception,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Erratum
4
- VERSION = '4.0.0'
4
+ VERSION = '4.1.0'
5
5
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erratum
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thegranddesign
@@ -37,7 +37,7 @@ cert_chain:
37
37
  3yXL4G6eW3rdBW/OiLF7GgG2o26d02OMzf4+ubUVS5LQDOcd4vgNPLWzJSBt1YIh
38
38
  TgBsED7Me5YdMVXxtTWYsF1VMzaL9hReD3UXGcxe
39
39
  -----END CERTIFICATE-----
40
- date: 2022-07-09 00:00:00.000000000 Z
40
+ date: 2022-07-18 00:00:00.000000000 Z
41
41
  dependencies:
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: apple_core
@@ -179,7 +179,7 @@ metadata:
179
179
  allowed_push_host: https://rubygems.org
180
180
  bug_tracker_uri: https://github.com/thekompanee/erratum/issues
181
181
  changelog_uri: https://github.com/thekompanee/erratum/blob/master/CHANGELOG.md
182
- documentation_uri: https://github.com/thekompanee/erratum/tree/releases/v4.0.0
182
+ documentation_uri: https://github.com/thekompanee/erratum/tree/releases/v4.1.0
183
183
  homepage_uri: https://github.com/thekompanee/erratum
184
184
  source_code_uri: https://github.com/thekompanee/erratum
185
185
  wiki_uri: https://github.com/thekompanee/erratum/wiki
metadata.gz.sig CHANGED
Binary file