human_error 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/human_error/error_code_directory.rb +1 -0
- data/lib/human_error/errors/authentication_errors/duplicate_authentication_error.rb +34 -0
- data/lib/human_error/errors/authentication_errors/invalid_token_error.rb +0 -6
- data/lib/human_error/errors/authentication_errors/invalid_username_or_password_error.rb +0 -6
- data/lib/human_error/errors/crud_errors/resource_persistence_error.rb +0 -7
- data/lib/human_error/errors.rb +1 -0
- data/lib/human_error/knowledgebase_id_directory.rb +1 -0
- data/lib/human_error/version.rb +1 -1
- data/spec/lib/human_error/errors/authentication_errors/duplicate_authentication_error_spec.rb +42 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b87c5a22db771619d2acebf4366be06025cf2fa
|
4
|
+
data.tar.gz: 9264a39f94e6c6b054b608564ada1347418c907f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2cf3e74bda9aca504b2f17aef58a0533d29df07f91974ca94d43a81427b408fd255acbc88b6de1c71d26c470a6c8f0dd28a92130417975530b3eba8e1205315
|
7
|
+
data.tar.gz: f14a129a5374268528578006185a1851168be6c7ef99c2d04da8337ffe83b1ff153ae3d8cca8964bf04bc1334b79e4b9076e858f0b32cb0b26de2b53976bdb7b
|
@@ -13,6 +13,7 @@ class ErrorCodeDirectory
|
|
13
13
|
'HumanError::Errors::ResourceNotFoundError' => 1005,
|
14
14
|
'HumanError::Errors::ResourcePersistenceError' => 1006,
|
15
15
|
'Apill::Errors::InvalidApiRequestError' => 1007,
|
16
|
+
'HumanError::Errors::DuplicateAuthenticationError' => 1008,
|
16
17
|
}
|
17
18
|
end
|
18
19
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'human_error/errors/request_error'
|
2
|
+
require 'human_error/errors/authentication_error'
|
3
|
+
|
4
|
+
module HumanError
|
5
|
+
module Errors
|
6
|
+
class DuplicateAuthenticationError < RequestError
|
7
|
+
include AuthenticationError
|
8
|
+
|
9
|
+
attr_accessor :provider,
|
10
|
+
:provider_user_id,
|
11
|
+
:user_id
|
12
|
+
|
13
|
+
def http_status
|
14
|
+
409
|
15
|
+
end
|
16
|
+
|
17
|
+
def developer_message
|
18
|
+
'The authentication you attempted to register has already been registered by another user. We do not currently support allowing multiple users to be connected to the same authentication.'
|
19
|
+
end
|
20
|
+
|
21
|
+
def developer_details
|
22
|
+
{
|
23
|
+
'provider' => provider,
|
24
|
+
'provider_user_id' => provider_user_id,
|
25
|
+
'user_id' => user_id,
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
def friendly_message
|
30
|
+
"Sorry! Someone else has already registered this #{provider} login."
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -9,13 +9,6 @@ class ResourcePersistenceError < RequestError
|
|
9
9
|
attr_accessor :errors,
|
10
10
|
:attributes
|
11
11
|
|
12
|
-
def initialize(errors: nil, attributes: nil, **args)
|
13
|
-
self.errors = errors
|
14
|
-
self.attributes = attributes
|
15
|
-
|
16
|
-
super **args
|
17
|
-
end
|
18
|
-
|
19
12
|
def http_status
|
20
13
|
422
|
21
14
|
end
|
data/lib/human_error/errors.rb
CHANGED
@@ -2,6 +2,7 @@ require 'human_error/errors/request_error'
|
|
2
2
|
require 'human_error/errors/authentication_error'
|
3
3
|
require 'human_error/errors/authentication_errors/invalid_token_error'
|
4
4
|
require 'human_error/errors/authentication_errors/invalid_username_or_password_error'
|
5
|
+
require 'human_error/errors/authentication_errors/duplicate_authentication_error'
|
5
6
|
require 'human_error/errors/crud_error'
|
6
7
|
require 'human_error/errors/crud_errors/resource_not_found_error'
|
7
8
|
require 'human_error/errors/crud_errors/resource_persistence_error'
|
@@ -13,6 +13,7 @@ class KnowledgebaseIdDirectory
|
|
13
13
|
'HumanError::Errors::ResourceNotFoundError' => '1234567890',
|
14
14
|
'HumanError::Errors::ResourcePersistenceError' => '1234567890',
|
15
15
|
'Apill::Errors::InvalidApiRequestError' => '1234567890',
|
16
|
+
'HumanError::Errors::DuplicateAuthenticationError' => '1234567890',
|
16
17
|
}
|
17
18
|
end
|
18
19
|
end
|
data/lib/human_error/version.rb
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'rspectacular'
|
2
|
+
require 'human_error/errors/authentication_errors/duplicate_authentication_error'
|
3
|
+
|
4
|
+
module HumanError
|
5
|
+
module Errors
|
6
|
+
describe DuplicateAuthenticationError do
|
7
|
+
let(:error) { DuplicateAuthenticationError.new(provider: 'flibbity',
|
8
|
+
provider_user_id: '12345',
|
9
|
+
user_id: '54321',) }
|
10
|
+
|
11
|
+
it 'has a status of 409' do
|
12
|
+
expect(error.http_status).to eql 409
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'has a code of 1008' do
|
16
|
+
expect(error.code).to eql 1008
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'has a knowledgebase article ID of 1234567890' do
|
20
|
+
expect(error.knowledgebase_article_id).to eql '1234567890'
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'can output the developer message' do
|
24
|
+
expect(error.developer_message).to eql 'The authentication you attempted to register has already been registered by another user. We do not currently support allowing multiple users to be connected to the same authentication.'
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'can output the developer details' do
|
28
|
+
expect(error.developer_details).to eql(
|
29
|
+
{
|
30
|
+
'provider' => 'flibbity',
|
31
|
+
'provider_user_id' => '12345',
|
32
|
+
'user_id' => '54321',
|
33
|
+
}
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'can output the friendly message' do
|
38
|
+
expect(error.friendly_message).to eql 'Sorry! Someone else has already registered this flibbity login.'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: human_error
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jfelchner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- lib/human_error/error_code_directory.rb
|
68
68
|
- lib/human_error/errors.rb
|
69
69
|
- lib/human_error/errors/authentication_error.rb
|
70
|
+
- lib/human_error/errors/authentication_errors/duplicate_authentication_error.rb
|
70
71
|
- lib/human_error/errors/authentication_errors/invalid_token_error.rb
|
71
72
|
- lib/human_error/errors/authentication_errors/invalid_username_or_password_error.rb
|
72
73
|
- lib/human_error/errors/crud_error.rb
|
@@ -78,6 +79,7 @@ files:
|
|
78
79
|
- lib/human_error/version.rb
|
79
80
|
- spec/lib/human_error/configuration_spec.rb
|
80
81
|
- spec/lib/human_error/error_spec.rb
|
82
|
+
- spec/lib/human_error/errors/authentication_errors/duplicate_authentication_error_spec.rb
|
81
83
|
- spec/lib/human_error/errors/authentication_errors/invalid_token_error_spec.rb
|
82
84
|
- spec/lib/human_error/errors/authentication_errors/invalid_username_or_password_error_spec.rb
|
83
85
|
- spec/lib/human_error/errors/crud_errors/resource_not_found_error_spec.rb
|
@@ -110,6 +112,7 @@ summary: Common Error Extensions and Helpers
|
|
110
112
|
test_files:
|
111
113
|
- spec/lib/human_error/configuration_spec.rb
|
112
114
|
- spec/lib/human_error/error_spec.rb
|
115
|
+
- spec/lib/human_error/errors/authentication_errors/duplicate_authentication_error_spec.rb
|
113
116
|
- spec/lib/human_error/errors/authentication_errors/invalid_token_error_spec.rb
|
114
117
|
- spec/lib/human_error/errors/authentication_errors/invalid_username_or_password_error_spec.rb
|
115
118
|
- spec/lib/human_error/errors/crud_errors/resource_not_found_error_spec.rb
|