human_error 1.13.0 → 1.13.3
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/Rakefile +1 -1
- data/lib/human_error/configuration.rb +3 -3
- data/lib/human_error/error.rb +3 -3
- data/lib/human_error/error_code_directory.rb +0 -2
- data/lib/human_error/errors/authentication_errors/duplicate_authentication_error.rb +6 -4
- data/lib/human_error/errors/authentication_errors/invalid_token_error.rb +2 -1
- data/lib/human_error/errors/authentication_errors/invalid_username_or_password_error.rb +3 -2
- data/lib/human_error/errors/crud_error.rb +7 -1
- data/lib/human_error/errors/crud_errors/association_error.rb +5 -3
- data/lib/human_error/errors/crud_errors/resource_not_found_error.rb +3 -2
- data/lib/human_error/errors/crud_errors/resource_persistence_error.rb +2 -1
- data/lib/human_error/errors/request_error.rb +2 -2
- data/lib/human_error/knowledgebase_id_directory.rb +0 -2
- data/lib/human_error/persistable.rb +8 -8
- data/lib/human_error/rescuable_resource.rb +3 -1
- data/lib/human_error/utilities/string.rb +6 -4
- data/lib/human_error/version.rb +1 -1
- data/spec/lib/human_error/configuration_spec.rb +1 -1
- data/spec/lib/human_error/errors/authentication_errors/duplicate_authentication_error_spec.rb +15 -10
- data/spec/lib/human_error/errors/authentication_errors/invalid_token_error_spec.rb +3 -1
- data/spec/lib/human_error/errors/authentication_errors/invalid_username_or_password_error_spec.rb +6 -3
- data/spec/lib/human_error/errors/crud_errors/association_error_spec.rb +5 -2
- data/spec/lib/human_error/errors/crud_errors/resource_not_found_error_spec.rb +8 -4
- data/spec/lib/human_error/errors/crud_errors/resource_persistence_error_spec.rb +7 -4
- data/spec/lib/human_error/errors/request_error_spec.rb +33 -33
- data/spec/lib/human_error_spec.rb +9 -4
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c394fa00941174a6e152654477b2214034b41175
|
4
|
+
data.tar.gz: 4c88363e4f4a1f840f33738ea969c165c47c60ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1c953c6f85b4a22855da2694719be0c825736e0582ca2c0706d6b59872a957966347a399a6e08b13eadf2e00d25ad81a336c9d40c9b78a024a2ba95b05e524c
|
7
|
+
data.tar.gz: b14efed87f7bf7334b6b78c537058bdf01e192ed3233c9eb054342a85bffa4f3073a2283b0ced25301693025ed43b7f8d1ae7bda28f7404364dfa1f393b25466
|
data/Rakefile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -6,9 +6,9 @@ class HumanError
|
|
6
6
|
|
7
7
|
def to_h
|
8
8
|
{
|
9
|
-
knowledgebase_url:
|
10
|
-
api_error_documentation_url:
|
11
|
-
api_version:
|
9
|
+
knowledgebase_url: knowledgebase_url,
|
10
|
+
api_error_documentation_url: api_error_documentation_url,
|
11
|
+
api_version: api_version,
|
12
12
|
}
|
13
13
|
end
|
14
14
|
end
|
data/lib/human_error/error.rb
CHANGED
@@ -26,7 +26,7 @@ module Error
|
|
26
26
|
self.knowledgebase_url = configuration.knowledgebase_url
|
27
27
|
|
28
28
|
args.each do |variable, value|
|
29
|
-
|
29
|
+
send("#{variable}=", value)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -46,7 +46,7 @@ module Error
|
|
46
46
|
"#{knowledgebase_url}/#{knowledgebase_article_id}"
|
47
47
|
end
|
48
48
|
|
49
|
-
def to_json(
|
49
|
+
def to_json(_options = {})
|
50
50
|
JSON.dump(as_json)
|
51
51
|
end
|
52
52
|
|
@@ -61,7 +61,7 @@ module Error
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def developer_message
|
64
|
-
|
64
|
+
fail NoMethodError, 'This method must be implemented in a subclass'
|
65
65
|
end
|
66
66
|
|
67
67
|
def self.included(base)
|
@@ -15,14 +15,16 @@ class DuplicateAuthenticationError < RequestError
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def developer_message
|
18
|
-
'The authentication you attempted to register has already been registered by
|
18
|
+
'The authentication you attempted to register has already been registered by ' \
|
19
|
+
'another user. We do not currently support allowing multiple users to be connected ' \
|
20
|
+
'to the same authentication.'
|
19
21
|
end
|
20
22
|
|
21
23
|
def developer_details
|
22
24
|
{
|
23
|
-
'provider'
|
24
|
-
'provider_user_id'
|
25
|
-
'user_id'
|
25
|
+
'provider' => provider,
|
26
|
+
'provider_user_id' => provider_user_id,
|
27
|
+
'user_id' => user_id,
|
26
28
|
}
|
27
29
|
end
|
28
30
|
|
@@ -13,7 +13,8 @@ class InvalidTokenError < RequestError
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def developer_message
|
16
|
-
'The token you attempted to use for this request is invalid for this resource.
|
16
|
+
'The token you attempted to use for this request is invalid for this resource. ' \
|
17
|
+
'Please double-check and try again.'
|
17
18
|
end
|
18
19
|
|
19
20
|
def developer_details
|
@@ -13,11 +13,12 @@ class InvalidUsernameOrPasswordError < RequestError
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def developer_message
|
16
|
-
'Either the username or password passed in or this request is invalid. Please
|
16
|
+
'Either the username or password passed in or this request is invalid. Please ' \
|
17
|
+
'double-check and try again.'
|
17
18
|
end
|
18
19
|
|
19
20
|
def developer_details
|
20
|
-
{ :
|
21
|
+
{ username: username, password: '[FILTERED]' }
|
21
22
|
end
|
22
23
|
|
23
24
|
def friendly_message
|
@@ -10,7 +10,13 @@ module CrudError
|
|
10
10
|
self.action = action || 'persist'
|
11
11
|
self.resource_id = resource_id
|
12
12
|
|
13
|
-
super
|
13
|
+
super(**args)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def resource_name_underscored
|
19
|
+
@resource_name_underscored ||= resource_name.gsub(/\s/, '_')
|
14
20
|
end
|
15
21
|
end
|
16
22
|
end
|
@@ -15,18 +15,20 @@ class AssociationError < RequestError
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def developer_message
|
18
|
-
"The #{association_name} that you attempted to associate with
|
18
|
+
"The #{association_name} that you attempted to associate with " \
|
19
|
+
"the #{resource_name} was not valid."
|
19
20
|
end
|
20
21
|
|
21
22
|
def developer_details
|
22
23
|
{
|
23
24
|
resource_name => attributes,
|
24
|
-
"#{association_name} id" => association_id
|
25
|
+
"#{association_name} id" => association_id,
|
25
26
|
}
|
26
27
|
end
|
27
28
|
|
28
29
|
def friendly_message
|
29
|
-
"Sorry! There was a problem when we tried to set the #{association_name} on
|
30
|
+
"Sorry! There was a problem when we tried to set the #{association_name} on " \
|
31
|
+
"that #{resource_name}."
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
@@ -11,11 +11,12 @@ class ResourceNotFoundError < RequestError
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def developer_message
|
14
|
-
"The #{resource_name} you attempted to #{action} for this request is either
|
14
|
+
"The #{resource_name} you attempted to #{action} for this request is either " \
|
15
|
+
'not authorized for the authenticated user or does not exist.'
|
15
16
|
end
|
16
17
|
|
17
18
|
def developer_details
|
18
|
-
{ "#{
|
19
|
+
{ "#{resource_name_underscored}_id" => resource_id }
|
19
20
|
end
|
20
21
|
|
21
22
|
def friendly_message
|
@@ -14,7 +14,8 @@ class ResourcePersistenceError < RequestError
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def developer_message
|
17
|
-
"One or more of the attributes on the #{resource_name} you attempted
|
17
|
+
"One or more of the attributes on the #{resource_name} you attempted " \
|
18
|
+
"to #{action} is invalid."
|
18
19
|
end
|
19
20
|
|
20
21
|
def developer_details
|
@@ -11,7 +11,7 @@ class RequestError < RuntimeError
|
|
11
11
|
:developer_details,
|
12
12
|
:friendly_message
|
13
13
|
|
14
|
-
def as_json(
|
14
|
+
def as_json(_options = {})
|
15
15
|
{
|
16
16
|
error: {
|
17
17
|
status: http_status,
|
@@ -23,7 +23,7 @@ class RequestError < RuntimeError
|
|
23
23
|
developer_details: developer_details,
|
24
24
|
friendly_message_key: friendly_message_key,
|
25
25
|
friendly_message: friendly_message,
|
26
|
-
}
|
26
|
+
},
|
27
27
|
}
|
28
28
|
end
|
29
29
|
|
@@ -8,14 +8,14 @@ module Persistable
|
|
8
8
|
when /\ACouldn't find .* without an ID\z/
|
9
9
|
[]
|
10
10
|
when /\ACouldn't find .* with \'.*\'=([a-f0-9\-]+)/
|
11
|
-
[
|
11
|
+
[Regexp.last_match(1)]
|
12
12
|
when /\ACouldn't find all .* with \'.*\': ((?:[a-f0-9\-]+(?:, )?)+)/
|
13
|
-
|
13
|
+
Regexp.last_match(1).split(', ')
|
14
14
|
end
|
15
15
|
|
16
16
|
raise HumanError::Errors::ResourceNotFoundError.new(
|
17
|
-
resource_name:
|
18
|
-
resource_id:
|
17
|
+
resource_name: Persistable.human_error_resource_name(self),
|
18
|
+
resource_id: ids)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -32,11 +32,11 @@ module Persistable
|
|
32
32
|
association_name: association_name,
|
33
33
|
association_id: association_id,
|
34
34
|
attributes: attributes)
|
35
|
-
rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved
|
35
|
+
rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved
|
36
36
|
raise HumanError::Errors::ResourcePersistenceError.new(
|
37
|
-
resource_name:
|
38
|
-
attributes:
|
39
|
-
errors:
|
37
|
+
resource_name: Persistable.human_error_resource_name(self.class),
|
38
|
+
attributes: attributes,
|
39
|
+
errors: errors.full_messages)
|
40
40
|
end
|
41
41
|
|
42
42
|
def self.human_error_resource_name(klass)
|
@@ -5,7 +5,8 @@ require 'human_error/errors/crud_errors/association_error'
|
|
5
5
|
class HumanError
|
6
6
|
module RescuableResource
|
7
7
|
module ClassMethods
|
8
|
-
|
8
|
+
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Style/GuardClause
|
9
|
+
def rescue_resource(_resource_name, from:, via:)
|
9
10
|
lookup_library = via
|
10
11
|
|
11
12
|
if from.include? 'persistence'
|
@@ -51,6 +52,7 @@ module RescuableResource
|
|
51
52
|
end
|
52
53
|
end
|
53
54
|
end
|
55
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength, Style/GuardClause
|
54
56
|
end
|
55
57
|
|
56
58
|
def self.included(base)
|
@@ -3,10 +3,12 @@ module Utilities
|
|
3
3
|
class String
|
4
4
|
def self.underscore(other)
|
5
5
|
word = other.to_s.gsub('::', '/')
|
6
|
-
word.gsub!(/(?:([A-Za-z\d])|^)(?=\b|[^a-z])/)
|
7
|
-
|
8
|
-
|
9
|
-
word.
|
6
|
+
word.gsub!(/(?:([A-Za-z\d])|^)(?=\b|[^a-z])/) do
|
7
|
+
"#{Regexp.last_match(1)}#{Regexp.last_match(1) && ''}"
|
8
|
+
end
|
9
|
+
word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
|
10
|
+
word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
|
11
|
+
word.tr!('-', '_')
|
10
12
|
word.downcase!
|
11
13
|
word
|
12
14
|
end
|
data/lib/human_error/version.rb
CHANGED
data/spec/lib/human_error/errors/authentication_errors/duplicate_authentication_error_spec.rb
CHANGED
@@ -4,9 +4,11 @@ require 'human_error/errors/authentication_errors/duplicate_authentication_error
|
|
4
4
|
class HumanError
|
5
5
|
module Errors
|
6
6
|
describe DuplicateAuthenticationError do
|
7
|
-
let(:error)
|
8
|
-
|
9
|
-
|
7
|
+
let(:error) do
|
8
|
+
DuplicateAuthenticationError.new(provider: 'flibbity',
|
9
|
+
provider_user_id: '12345',
|
10
|
+
user_id: '54321')
|
11
|
+
end
|
10
12
|
|
11
13
|
it 'has a status of 409' do
|
12
14
|
expect(error.http_status).to eql 409
|
@@ -21,21 +23,24 @@ describe DuplicateAuthenticationError do
|
|
21
23
|
end
|
22
24
|
|
23
25
|
it 'can output the developer message' do
|
24
|
-
expect(error.developer_message).to eql 'The authentication you attempted to
|
26
|
+
expect(error.developer_message).to eql 'The authentication you attempted to ' \
|
27
|
+
'register has already been registered by ' \
|
28
|
+
'another user. We do not currently support ' \
|
29
|
+
'allowing multiple users to be connected to ' \
|
30
|
+
'the same authentication.'
|
25
31
|
end
|
26
32
|
|
27
33
|
it 'can output the developer details' do
|
28
34
|
expect(error.developer_details).to eql(
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
'user_id' => '54321',
|
33
|
-
}
|
35
|
+
'provider' => 'flibbity',
|
36
|
+
'provider_user_id' => '12345',
|
37
|
+
'user_id' => '54321',
|
34
38
|
)
|
35
39
|
end
|
36
40
|
|
37
41
|
it 'can output the friendly message' do
|
38
|
-
expect(error.friendly_message).to eql 'Sorry! Someone else has already registered
|
42
|
+
expect(error.friendly_message).to eql 'Sorry! Someone else has already registered ' \
|
43
|
+
'this flibbity login.'
|
39
44
|
end
|
40
45
|
end
|
41
46
|
end
|
@@ -19,7 +19,9 @@ describe InvalidTokenError do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'can output the developer message' do
|
22
|
-
expect(error.developer_message).to eql 'The token you attempted to use for this
|
22
|
+
expect(error.developer_message).to eql 'The token you attempted to use for this ' \
|
23
|
+
'request is invalid for this resource. ' \
|
24
|
+
'Please double-check and try again.'
|
23
25
|
end
|
24
26
|
|
25
27
|
it 'can output the developer details' do
|
data/spec/lib/human_error/errors/authentication_errors/invalid_username_or_password_error_spec.rb
CHANGED
@@ -19,17 +19,20 @@ describe InvalidUsernameOrPasswordError do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'can output the developer message' do
|
22
|
-
expect(error.developer_message).to eql 'Either the username or password passed in
|
22
|
+
expect(error.developer_message).to eql 'Either the username or password passed in ' \
|
23
|
+
'or this request is invalid. Please ' \
|
24
|
+
'double-check and try again.'
|
23
25
|
end
|
24
26
|
|
25
27
|
it 'can output the developer details' do
|
26
28
|
error = InvalidUsernameOrPasswordError.new username: 'neo'
|
27
29
|
|
28
|
-
expect(error.developer_details).to eql(:
|
30
|
+
expect(error.developer_details).to eql(username: 'neo', password: '[FILTERED]')
|
29
31
|
end
|
30
32
|
|
31
33
|
it 'can output the friendly message' do
|
32
|
-
expect(error.friendly_message).to eql 'Either your email or password is
|
34
|
+
expect(error.friendly_message).to eql 'Either your email or password is ' \
|
35
|
+
'incorrect. Please double-check and try again.'
|
33
36
|
end
|
34
37
|
end
|
35
38
|
end
|
@@ -22,7 +22,9 @@ describe AssociationError do
|
|
22
22
|
error = AssociationError.new association_name: 'black leather trenchcoat',
|
23
23
|
resource_name: 'Neo'
|
24
24
|
|
25
|
-
expect(error.developer_message).to eql
|
25
|
+
expect(error.developer_message).to eql 'The black leather trenchcoat that you ' \
|
26
|
+
'attempted to associate with the Neo was ' \
|
27
|
+
'not valid.'
|
26
28
|
end
|
27
29
|
|
28
30
|
it 'includes the resource name and action in the developer details' do
|
@@ -41,7 +43,8 @@ describe AssociationError do
|
|
41
43
|
error = AssociationError.new association_name: 'black leather trenchcoat',
|
42
44
|
resource_name: 'Neo'
|
43
45
|
|
44
|
-
expect(error.friendly_message).to eql
|
46
|
+
expect(error.friendly_message).to eql 'Sorry! There was a problem when we tried to ' \
|
47
|
+
'set the black leather trenchcoat on that Neo.'
|
45
48
|
end
|
46
49
|
end
|
47
50
|
end
|
@@ -22,28 +22,32 @@ describe ResourceNotFoundError do
|
|
22
22
|
error = ResourceNotFoundError.new resource_name: 'black leather trenchcoat',
|
23
23
|
action: 'bullet time'
|
24
24
|
|
25
|
-
expect(error.developer_message).to eql
|
25
|
+
expect(error.developer_message).to eql 'The black leather trenchcoat you attempted ' \
|
26
|
+
'to bullet time for this request is either ' \
|
27
|
+
'not authorized for the authenticated user ' \
|
28
|
+
'or does not exist.'
|
26
29
|
end
|
27
30
|
|
28
31
|
it 'includes the resource name and action in the developer details' do
|
29
32
|
error = ResourceNotFoundError.new resource_name: 'black leather trenchcoat',
|
30
33
|
resource_id: 123
|
31
34
|
|
32
|
-
expect(error.developer_details).to eql(
|
35
|
+
expect(error.developer_details).to eql('black_leather_trenchcoat_id' => 123)
|
33
36
|
end
|
34
37
|
|
35
38
|
it 'can accept an array of IDs' do
|
36
39
|
error = ResourceNotFoundError.new resource_name: 'black leather trenchcoat',
|
37
40
|
resource_id: %w{123 456}
|
38
41
|
|
39
|
-
expect(error.developer_details).to eql(
|
42
|
+
expect(error.developer_details).to eql('black_leather_trenchcoat_id' => %w{123 456})
|
40
43
|
end
|
41
44
|
|
42
45
|
it 'includes the resource name and action in the friendly message' do
|
43
46
|
error = ResourceNotFoundError.new resource_name: 'black leather trenchcoat',
|
44
47
|
action: 'bullet time'
|
45
48
|
|
46
|
-
expect(error.friendly_message).to eql
|
49
|
+
expect(error.friendly_message).to eql 'Sorry! The black leather trenchcoat you ' \
|
50
|
+
'tried to bullet time does not exist.'
|
47
51
|
end
|
48
52
|
end
|
49
53
|
end
|
@@ -22,12 +22,14 @@ describe ResourcePersistenceError do
|
|
22
22
|
error = ResourcePersistenceError.new resource_name: 'black leather trenchcoat',
|
23
23
|
action: 'bullet time'
|
24
24
|
|
25
|
-
expect(error.developer_message).to eql
|
25
|
+
expect(error.developer_message).to eql 'One or more of the attributes on the black ' \
|
26
|
+
'leather trenchcoat you attempted to bullet ' \
|
27
|
+
'time is invalid.'
|
26
28
|
end
|
27
29
|
|
28
30
|
it 'includes the resource name and action in the developer details' do
|
29
|
-
error = ResourcePersistenceError.new errors:
|
30
|
-
attributes:
|
31
|
+
error = ResourcePersistenceError.new errors: 'lots of errors',
|
32
|
+
attributes: 'what is the matrix'
|
31
33
|
|
32
34
|
expect(error.developer_details).to eql('errors' => 'lots of errors',
|
33
35
|
'attributes' => 'what is the matrix')
|
@@ -37,7 +39,8 @@ describe ResourcePersistenceError do
|
|
37
39
|
error = ResourcePersistenceError.new resource_name: 'black leather trenchcoat',
|
38
40
|
action: 'bullet time'
|
39
41
|
|
40
|
-
expect(error.friendly_message).to eql
|
42
|
+
expect(error.friendly_message).to eql 'Sorry! We had a problem when tried to ' \
|
43
|
+
'bullet time that black leather trenchcoat.'
|
41
44
|
end
|
42
45
|
end
|
43
46
|
end
|
@@ -5,17 +5,18 @@ class HumanError
|
|
5
5
|
module Errors
|
6
6
|
describe RequestError do
|
7
7
|
it 'can generate error data' do
|
8
|
-
request_error = RequestError.new(
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
8
|
+
request_error = RequestError.new(
|
9
|
+
http_status: 'flibbity',
|
10
|
+
code: 'jibbit',
|
11
|
+
developer_message: 'I cannot receive any satisfaction',
|
12
|
+
developer_details: 'But perhaps if I attempt it one more time, I can',
|
13
|
+
friendly_message: 'receive what I need',
|
14
|
+
knowledgebase_article_id: '87654321',
|
15
|
+
api_version: 'janky',
|
16
|
+
api_error_documentation_url: 'asimof',
|
17
|
+
knowledgebase_url: 'jinkies')
|
17
18
|
|
18
|
-
expect(request_error.as_json).to eql(
|
19
|
+
expect(request_error.as_json).to eql(
|
19
20
|
error: {
|
20
21
|
status: 'flibbity',
|
21
22
|
code: 'jibbit',
|
@@ -26,8 +27,7 @@ describe RequestError do
|
|
26
27
|
developer_details: 'But perhaps if I attempt it one more time, I can',
|
27
28
|
friendly_message_key: 'errors.request.error.friendly',
|
28
29
|
friendly_message: 'receive what I need',
|
29
|
-
}
|
30
|
-
})
|
30
|
+
})
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'can extract configuration from the global config if it is not passed in' do
|
@@ -37,14 +37,15 @@ describe RequestError do
|
|
37
37
|
config.knowledgebase_url = 'jinkies'
|
38
38
|
end
|
39
39
|
|
40
|
-
request_error = RequestError.new(
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
40
|
+
request_error = RequestError.new(
|
41
|
+
http_status: 'flibbity',
|
42
|
+
code: 'jibbit',
|
43
|
+
developer_message: 'I cannot receive any satisfaction',
|
44
|
+
developer_details: 'But perhaps if I attempt it one more time, I can',
|
45
|
+
friendly_message: 'receive what I need',
|
46
|
+
knowledgebase_article_id: '87654321')
|
46
47
|
|
47
|
-
expect(request_error.as_json).to eql(
|
48
|
+
expect(request_error.as_json).to eql(
|
48
49
|
error: {
|
49
50
|
status: 'flibbity',
|
50
51
|
code: 'jibbit',
|
@@ -55,8 +56,7 @@ describe RequestError do
|
|
55
56
|
developer_details: 'But perhaps if I attempt it one more time, I can',
|
56
57
|
friendly_message_key: 'errors.request.error.friendly',
|
57
58
|
friendly_message: 'receive what I need',
|
58
|
-
}
|
59
|
-
})
|
59
|
+
})
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'can override the global config if it is set, but an explicit value is passed in' do
|
@@ -66,17 +66,18 @@ describe RequestError do
|
|
66
66
|
config.knowledgebase_url = 'jinkies'
|
67
67
|
end
|
68
68
|
|
69
|
-
request_error = RequestError.new(
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
69
|
+
request_error = RequestError.new(
|
70
|
+
http_status: 'flibbity',
|
71
|
+
code: 'jibbit',
|
72
|
+
developer_message: 'I cannot receive any satisfaction',
|
73
|
+
developer_details: 'But perhaps if I attempt it one more time, I can',
|
74
|
+
friendly_message: 'receive what I need',
|
75
|
+
knowledgebase_article_id: '87654321',
|
76
|
+
api_version: 'hanky',
|
77
|
+
api_error_documentation_url: 'hasimof',
|
78
|
+
knowledgebase_url: 'hinkies')
|
78
79
|
|
79
|
-
expect(request_error.as_json).to eql(
|
80
|
+
expect(request_error.as_json).to eql(
|
80
81
|
error: {
|
81
82
|
status: 'flibbity',
|
82
83
|
code: 'jibbit',
|
@@ -87,8 +88,7 @@ describe RequestError do
|
|
87
88
|
developer_details: 'But perhaps if I attempt it one more time, I can',
|
88
89
|
friendly_message_key: 'errors.request.error.friendly',
|
89
90
|
friendly_message: 'receive what I need',
|
90
|
-
}
|
91
|
-
})
|
91
|
+
})
|
92
92
|
end
|
93
93
|
end
|
94
94
|
end
|
@@ -9,7 +9,7 @@ describe HumanError do
|
|
9
9
|
it 'can configure each instance' do
|
10
10
|
human_error = HumanError.new do |config|
|
11
11
|
config.api_version = 'foo'
|
12
|
-
|
12
|
+
end
|
13
13
|
|
14
14
|
expect(human_error.configuration.api_version).to eql 'foo'
|
15
15
|
end
|
@@ -30,7 +30,9 @@ describe HumanError do
|
|
30
30
|
expect(fetched_error.api_version).to eql 'foo'
|
31
31
|
end
|
32
32
|
|
33
|
-
it 'can override values in the global configuration with values in the local
|
33
|
+
it 'can override values in the global configuration with values in the local' \
|
34
|
+
'configuration when looking up an error' do
|
35
|
+
|
34
36
|
HumanError.configure do |config|
|
35
37
|
config.api_version = 'bar'
|
36
38
|
end
|
@@ -44,7 +46,9 @@ describe HumanError do
|
|
44
46
|
expect(fetched_error.api_version).to eql 'foo'
|
45
47
|
end
|
46
48
|
|
47
|
-
it 'can override values in the local configuration with explicit values passed when
|
49
|
+
it 'can override values in the local configuration with explicit values passed when' \
|
50
|
+
'looking up an error' do
|
51
|
+
|
48
52
|
human_error = HumanError.new do |config|
|
49
53
|
config.api_version = 'foo'
|
50
54
|
end
|
@@ -57,6 +61,7 @@ describe HumanError do
|
|
57
61
|
it 'can raise an error' do
|
58
62
|
human_error = HumanError.new
|
59
63
|
|
60
|
-
expect { human_error.raise('RequestError') }.to
|
64
|
+
expect { human_error.raise('RequestError') }.to \
|
65
|
+
raise_error HumanError::Errors::RequestError
|
61
66
|
end
|
62
67
|
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.13.
|
4
|
+
version: 1.13.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jfelchner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
111
|
version: '0'
|
112
112
|
requirements: []
|
113
113
|
rubyforge_project:
|
114
|
-
rubygems_version: 2.
|
114
|
+
rubygems_version: 2.2.2
|
115
115
|
signing_key:
|
116
116
|
specification_version: 4
|
117
117
|
summary: Common Error Extensions and Helpers
|
@@ -127,3 +127,4 @@ test_files:
|
|
127
127
|
- spec/lib/human_error/errors/request_error_spec.rb
|
128
128
|
- spec/lib/human_error/rescuable_resource_spec.rb
|
129
129
|
- spec/lib/human_error_spec.rb
|
130
|
+
has_rdoc:
|