appfuel 0.6.9 → 0.6.10

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
  SHA1:
3
- metadata.gz: 96393eedf551347652df172f5210cbeda81ff7c6
4
- data.tar.gz: 6f40b8f60d923a6c781d60bea5cd6f7339b352a7
3
+ metadata.gz: 7ec72ecc281272f58256fc9f8cf939ecc26eb2e3
4
+ data.tar.gz: d523670b905bde9b2bdb524c5b0efc21877a6dca
5
5
  SHA512:
6
- metadata.gz: 0881078fe5377a38ece0400cf584a6a4d4a41c380c1971d52a321fdda4910d7d883b1f6088854d70482e8dd902fc4d38e047983d121a2be4fa83a358eb475641
7
- data.tar.gz: 40998d159dc2dcc7bb3344999b5bc770c9d44c486b3e32e2a3e643debe34299135c5fea3b6e5c482ddbaf5345f9e5d5cf111e736a5c0b04d17264f6f26573a4d
6
+ metadata.gz: 92f47cbb94d2d8a06371b994f9021e5a4ab23c65244deb5464731672cf68f6325308170fcd7e8a5eb7969d3ce7493277f836367940d2440a2e316d7f36b8055f
7
+ data.tar.gz: 3fa9c1990b8caa00dfadd7d2f8271d10a196e15f82fefeff709d2f375e93157cdf1e684d183fe0e3c885c5b82c4a244a62a9322c6b05e870497336fa7ca1ffe4
data/CHANGELOG.md CHANGED
@@ -5,10 +5,16 @@ All notable changes to this project will be documented in this file. (Pending ap
5
5
 
6
6
 
7
7
  # Releases
8
- ## [[0.6.9]](https://github.com/rsb/appfuel/releases/tag/0.6.7) 2017-09-12
8
+ ## [[0.6.9]](https://github.com/rsb/appfuel/releases/tag/0.6.10) 2017-09-21
9
+ ### Added
10
+ - adding error handling lambda that can be injected into the container and used
11
+ in the two different rescue blocks of the dispatcher
12
+
13
+ ## [[0.6.9]](https://github.com/rsb/appfuel/releases/tag/0.6.9) 2017-09-12
14
+ ### Fixed
9
15
  - `web_api` fix content_type check for json
10
16
 
11
- ## [[0.6.8]](https://github.com/rsb/appfuel/releases/tag/0.6.7) 2017-08-24
17
+ ## [[0.6.8]](https://github.com/rsb/appfuel/releases/tag/0.6.8) 2017-08-24
12
18
  ### Fixed
13
19
  - `batch_get` typo fixed in dynamodb params requested_items to request_items
14
20
 
@@ -8,14 +8,40 @@ module Appfuel
8
8
  action = container[:action_loader].call(request.namespace, container)
9
9
  response = action.run(request.inputs)
10
10
  rescue Appfuel::Handler::HandlerFailure => e
11
- response = e.response
11
+ error_handler_key = :dispatcher_action_error_handler
12
+ response = handle_exception(error_handler_key, e, container)
12
13
  rescue => e
13
- handler = Appfuel::ResponseHandler.new
14
- response = handler.error(e)
14
+ error_handler_key = :dispatcher_general_error_handler
15
+ response = handle_exception(error_handler_key, e, container)
15
16
  end
16
17
 
17
18
  response
18
19
  end
20
+
21
+ def handle_exception(error_handler_key, e, container)
22
+ logger = container[:logger]
23
+ load_error_handler(error_handler_key, container).call(e, logger)
24
+ if error_handler_key == :dispatcher_action_error_handler
25
+ return e.response
26
+ end
27
+
28
+ Appfuel::ResponseHandler.new.error(e)
29
+ end
30
+
31
+ def load_error_handler(key, container)
32
+ handler = default_exception_handler
33
+ if container.key?(key)
34
+ handler = container[key]
35
+ end
36
+ handler
37
+ end
38
+
39
+ def default_exception_handler
40
+ ->(e, logger = nil) {
41
+ logger ||= Logger.new(STDOUT)
42
+ logger.error "#{e.class.to_s} #{e.to_s} #{e.backtrace.join("\n")}"
43
+ }
44
+ end
19
45
  end
20
46
  end
21
47
  end
@@ -1,3 +1,3 @@
1
1
  module Appfuel
2
- VERSION = "0.6.9"
2
+ VERSION = "0.6.10"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appfuel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.9
4
+ version: 0.6.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Scott-Buccleuch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-13 00:00:00.000000000 Z
11
+ date: 2017-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord