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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/erratum/configuration.rb +1 -0
- data/lib/erratum/errors/crud/resource_persistence.rb +36 -0
- data/lib/erratum/rescuable_resource.rb +7 -6
- data/lib/erratum/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42348e001695f75bef48c2fc53216daeefb1d818c6a7c84e9029d919eddd65ac
|
4
|
+
data.tar.gz: 5526924695f72382843eef7bbe142908a3d9b744aabb7377c43aae98803ef937
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 '
|
11
|
-
'
|
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::
|
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,
|
data/lib/erratum/version.rb
CHANGED
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.
|
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-
|
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.
|
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
|