error_response 0.2.3 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/error_response.rb +14 -2
  3. metadata +5 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc196d31f6efba6daf505398631854613de7c94c9b6b4e3e365bcc44519d0b31
4
- data.tar.gz: 5b0ed90c4275256fd5fca3b26463826b8a8f1f9df83bf62b604cab923930e9ed
3
+ metadata.gz: f5eed589e50b7780b64e7bb326c6d73e971d1ac37e3c0be4d00aa78ab28d7b9c
4
+ data.tar.gz: 8e9280cea3e10897368959b1901cd01cb616accc1c9eb835f412c452e1628aaa
5
5
  SHA512:
6
- metadata.gz: 14ac71c26ddec3ec948131b0e0f2c5e1d6fde6775abde8513d21d621148a0015012207eb5c5f9fdace369ae75ca74d9b6d6c639e368f8b1a1f8ee3033abf6294
7
- data.tar.gz: 3d012a284a580986cadfcf9c103779642eca3cb4b6a734b4c548bccaade20a8f5e9acfe1b1a426c4117120dc14c4b5e47e059918c46a00ff1a90c5d6cd0eee3c
6
+ metadata.gz: f855a6bcb29eb546a38d249aa3fade61974fbfd26d6a2085e09127736ad1f077dc8d0653b3184f49de9b9a17df7b0018de8e9192cd100f80fedb989e10e03c4f
7
+ data.tar.gz: b36effef06aa210e0653de9418ea8ddf4b6a85ab50819e67df59c28ef3bcf4489f8e5025a98395dca42faa87e28906323abf3223a1963bb91b599bfab70f207a
@@ -3,7 +3,13 @@ class ErrorResponse
3
3
  YAML_PATH = 'config/error_response.yml'
4
4
 
5
5
  def self.to_api(key, message=nil)
6
- err_json = yaml_hash[key.to_s] || {'error_code' => 500000, 'error_message' => message}
6
+ err_json = yaml_hash[key.to_s]&.dup
7
+ err_json['error_key'] = key.to_s if !err_json.nil? && !key.nil? && yaml_hash.key?(key.to_s)
8
+ if err_json.nil?
9
+ err_json = {'error_code' => 500000, 'error_message' => message}
10
+ elsif !message.nil?
11
+ err_json['error_message'] += ": #{message}"
12
+ end
7
13
 
8
14
  status = err_json['error_code'] / 1000
9
15
  {
@@ -13,7 +19,13 @@ class ErrorResponse
13
19
  end
14
20
 
15
21
  def self.to_hash(key)
16
- yaml_hash[key.to_s] || {}
22
+ if yaml_hash.key?(key.to_s)
23
+ result = yaml_hash[key.to_s]
24
+ result['error_key'] = key.to_s
25
+ else
26
+ result = nil
27
+ end
28
+ result
17
29
  end
18
30
 
19
31
  def self.all
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: error_response
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
- - jameslee
7
+ - Kdan Mobile Software Developer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-08 00:00:00.000000000 Z
11
+ date: 2020-08-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: use for error_response
14
- email: jameslee@kdanmobile.com
14
+ email: dev@kdanmobile.com
15
15
  executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
@@ -36,7 +36,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
36
36
  - !ruby/object:Gem::Version
37
37
  version: '0'
38
38
  requirements: []
39
- rubygems_version: 3.0.6
39
+ rubygems_version: 3.0.3
40
40
  signing_key:
41
41
  specification_version: 4
42
42
  summary: A tool for API error response