service_caller 1.0.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31797557043d5fec9f9a5fa9497e0676742038ed7af367ffb5a0a9ab68bfd342
4
- data.tar.gz: b3e2bf861756cc2c5bb5998801144366cc255cd6c3e564a91e6d8c218fc1305f
3
+ metadata.gz: 4270b7ad52ef57a18ba599c31496415626a298ab824884c416c1b5ff51af75c2
4
+ data.tar.gz: 627575a83678d20e7ec951b1ac9c4777acdcf91e2ae620e2b99c59ccef5b46c6
5
5
  SHA512:
6
- metadata.gz: 1e426cec96768b798867683ddbc5962c0b361113574daaf7ec83c4e43f0fbb7358cdffb4dcea5a1440da9ae40e521610d6acfa58966ae3c07d52e5fe8846a0ee
7
- data.tar.gz: 92faf376fac110cb0bf16b1e6ada0550690f35f038108f1704d18d6376e706828808280d17b0d1bc0e3974aebefa971a5652499f473d2915b78b7a50673e0fbd
6
+ metadata.gz: 1ce323d5562bb0fb08d42121858dfa19c4cf691f5afe27a11c3781ce8475b190ea7b5c4593f71a924908317c2447c2b03b3e6adbcd81471dea41b956970df2ea
7
+ data.tar.gz: 796dd3b3e3b64fc4e58b76a12778e2436758b62f4305bda9c2896a3278a340d45c12b220f1379933e0dd43d6aebbcb3319cdb6b1c07832af28611c0d6ea7b657
@@ -3,8 +3,10 @@ class ServiceError < StandardError
3
3
  attr_reader :error_obj
4
4
 
5
5
  class << self
6
- def generate_from_exception(exception)
7
- service_err = new(:internal_error, error_msg: "#{exception.class.name}: #{exception.message}")
6
+ def generate_from_exception(exception, append_info={})
7
+ error_obj = {error_message: "#{exception.class.name}: #{exception.message}"}
8
+ error_obj.merge!(append_info)
9
+ service_err = new(:internal_error, error_obj)
8
10
  service_err.set_backtrace(exception.backtrace)
9
11
  service_err
10
12
  end
@@ -12,7 +14,8 @@ class ServiceError < StandardError
12
14
 
13
15
  def initialize(key, error_obj={})
14
16
  @key = key
17
+ error_message = error_obj.delete(:error_message) || key
15
18
  @error_obj = error_obj
16
- super(error_obj[:error_msg] || key)
19
+ super(error_message)
17
20
  end
18
21
  end
@@ -2,13 +2,13 @@ module ServiceExtend
2
2
  module Handler
3
3
 
4
4
  def call
5
- if defined?(::Rails::Engine)
5
+ if defined?(::Rails::Engine) && defined?(::ActiveRecord)
6
6
  begin
7
7
  super
8
8
  rescue ServiceError => e
9
9
  @error = e
10
10
  rescue ActiveRecord::RecordNotFound => e
11
- @error = ServiceError.new(:record_not_found, e.message)
11
+ @error = ServiceError.new(:record_not_found, error_message: e.message)
12
12
  @error.set_backtrace(e.backtrace)
13
13
  rescue Exception => e
14
14
  @error = ServiceError.generate_from_exception(e)
@@ -25,4 +25,4 @@ module ServiceExtend
25
25
  end
26
26
 
27
27
  end
28
- end
28
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: service_caller
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JiaRou Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-16 00:00:00.000000000 Z
11
+ date: 2020-08-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: basic implement of service object
14
14
  email: laura34963@kdanmobile.com
@@ -42,7 +42,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
42
42
  - !ruby/object:Gem::Version
43
43
  version: '0'
44
44
  requirements: []
45
- rubygems_version: 3.0.1
45
+ rubygems_version: 3.0.3
46
46
  signing_key:
47
47
  specification_version: 4
48
48
  summary: Ruby Service Basic Class