error_response 1.0.2 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/error_response.rb +9 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 942aeb3cb71ffd7c3adff6fd0d30d200ec1179eac0252f9c3d73c19530ef3226
|
4
|
+
data.tar.gz: 077bcdd308abe7d3eaf1a849594b9f25d056e52447c83a7b93ce6014d440c19b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64c7a9948a528a8cb85c188538cb885802483e4752aa8ad98fcad13e5f4cd65245e78dc5f5c8967a26c3345d3668b46b06840a2bd77207396f4b2075ca97d62b
|
7
|
+
data.tar.gz: a27250609dee2141be6f848f95588ea150b8f6ff9d080886ba47175b6fea7476e56fa13487e5e335e4508e9de479c993a4c3a0b76a53e712d43a24f70a88703a
|
data/lib/error_response.rb
CHANGED
@@ -14,16 +14,11 @@ class ErrorResponse
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.to_api(key, message=nil)
|
17
|
-
|
18
|
-
|
19
|
-
json: { 'error_code' => 500_000, 'error_message' => message }
|
20
|
-
}
|
21
|
-
return default_result unless yaml_hash.key?(key.to_s)
|
22
|
-
|
23
|
-
json = yaml_hash[key.to_s].merge({ 'error_key' => key.to_s })
|
17
|
+
json = yaml_hash[key.to_s] || { 'error_code' => 500_000, 'error_message' => key.to_s }
|
18
|
+
json['error_key'] = key.to_s
|
24
19
|
json['error_message'] += ": #{message}" unless message.nil?
|
25
20
|
{
|
26
|
-
status: json['error_code']
|
21
|
+
status: parse_status(json['error_code']),
|
27
22
|
json: json
|
28
23
|
}
|
29
24
|
end
|
@@ -39,12 +34,16 @@ class ErrorResponse
|
|
39
34
|
|
40
35
|
remote_array = settings['source']['remote']
|
41
36
|
remote_hash = remote_array.nil? ? {} : remote_array.map { |url| build_yaml(url) }.inject(&:merge)
|
42
|
-
|
37
|
+
|
43
38
|
@hash = local_hash.merge(remote_hash)
|
44
39
|
end
|
45
40
|
|
46
41
|
def self.build_yaml(url)
|
47
|
-
content = open(url){|f| f.read}
|
42
|
+
content = URI.open(url){|f| f.read}
|
48
43
|
YAML.load(content)
|
49
44
|
end
|
45
|
+
|
46
|
+
def self.parse_status(error_code)
|
47
|
+
error_code.to_s[0..2].to_i
|
48
|
+
end
|
50
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: error_response
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kdan Mobile Software Developer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: use for error_response
|
14
14
|
email: dev@kdanmobile.com
|