rack-parser 0.5.0 → 0.6.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2bfc0d8a49d8bbfbea8feb0f9760dd7ddc4ab9a4
4
- data.tar.gz: b2012859f92dc0317ca7d3db060ed82aececaf31
3
+ metadata.gz: 3a7ddcfcf164a59f2e0a35d8dbc197e742c715db
4
+ data.tar.gz: cb8b0b947daa30f8ef17276d1d2f81a16897b907
5
5
  SHA512:
6
- metadata.gz: dcbf8aad748d39e46dd18557c44184bd5500ca38d55420f5e30f16b6b8aabfbc4577ccae569658c4c269b74ed80d91d47dfc9c3b22c8926fde5c6ea88988a152
7
- data.tar.gz: e73679c51a235e0983fdca3bbb9b2fded19ebb8d0ec62da4ae486d35340c702df403314f6bf7adaa219f36cbad1746397eba9158e8c19f299d1e3ca664552094
6
+ metadata.gz: b19155797c75b417c940feb83f10ff6384833215db9b010415e674aad87894f992d49aeb5440b45d4b03fc644493ee2a280f5825f7e2783f862228b94b2fff23
7
+ data.tar.gz: 8ad8459f09be43fc97dbd1b5baf382da16a2e1e94745bf011b5d258b1cf36dad111a5235ba81b2d20926826214e05b9e86489314bb907ccd0904c6aaa7fb9ba1
data/README.md CHANGED
@@ -67,6 +67,9 @@ override the default response as well.
67
67
 
68
68
  If no content_type error handling response is present, it will return `400`
69
69
 
70
+ Do note, the error handler rescues exceptions that are descents of `StandardError`. See
71
+ http://www.mikeperham.com/2012/03/03/the-perils-of-rescue-exception/
72
+
70
73
  ### Regex Matching ###
71
74
 
72
75
  With version `0.4.0`, you can specify regex matches for the content
@@ -99,7 +102,7 @@ This project came to being because of:
99
102
  * [Moonsik Kang](https://github.com/deepblue) - skip rack parser for content types that are not explicitly set.
100
103
  * [Guillermo Iguaran](https://github.com/guilleiguaran) - Updating `multi_xml` version dependency for XML/YAML exploit
101
104
  * [Doug Orleans](https://github.com/dougo) - Handle only post-body parsing errors and let upstream errors propogate downstream
102
- * [Akshay Moghe](https://github.com/amoghe) - Make default error handler rack compliant by responding to #each
105
+ * [Akshay Moghe](https://github.com/amoghe) - Make default error handler rack compliant by responding to #each and use StandardError
103
106
 
104
107
  ## Copyright
105
108
 
@@ -30,7 +30,7 @@ module Rack
30
30
  begin
31
31
  parsed = parser.last.call body
32
32
  env.update FORM_HASH => parsed, FORM_INPUT => env[POST_BODY]
33
- rescue Exception => e
33
+ rescue StandardError => e
34
34
  warn! e, type
35
35
  handler = handlers.detect { |content_type, _| type.match(content_type) }
36
36
  handler ||= ['default', ERROR_HANDLER]
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "rack-parser"
6
- s.version = "0.5.0"
6
+ s.version = "0.6.0"
7
7
  s.authors = ["Arthur Chiu"]
8
8
  s.email = ["mr.arthur.chiu@gmail.com"]
9
9
  s.homepage = "https://www.github.com/achiu/rack-parser"
@@ -43,7 +43,7 @@ describe Rack::Parser do
43
43
  end
44
44
 
45
45
  it "handles upstream errors" do
46
- assert_raises Exception, 'error!' do
46
+ assert_raises StandardError, 'error!' do
47
47
  parser = proc { |data| JSON.parse data }
48
48
  stack Rack::Parser, :parsers => { %r{json} => parser }
49
49
  post '/error', '{}', { 'CONTENT_TYPE' => 'application/json' }
@@ -51,7 +51,7 @@ describe Rack::Parser do
51
51
  end
52
52
 
53
53
  it "returns a default error" do
54
- parser = proc { |data| raise Exception, 'wah wah' }
54
+ parser = proc { |data| raise StandardError, 'wah wah' }
55
55
  stack Rack::Parser, :parsers => { %r{json} => parser }
56
56
  post '/post', '{}', { 'CONTENT_TYPE' => 'application/vnd.foo+json' }
57
57
 
@@ -59,7 +59,7 @@ describe Rack::Parser do
59
59
  end
60
60
 
61
61
  it "returns a custom error message" do
62
- parser = proc { |data| raise Exception, "wah wah" }
62
+ parser = proc { |data| raise StandardError, "wah wah" }
63
63
  handler = proc { |err, type| [500, {}, "%s : %s" % [type, err]] }
64
64
  stack Rack::Parser, :parsers => { %r{json} => parser },
65
65
  :handlers => { %r{json} => handler }
@@ -14,7 +14,7 @@ class ParserApp
14
14
  case request.path
15
15
  when '/' then [200, 'Hello World']
16
16
  when '/post' then [200, request.params.inspect]
17
- when '/error' then raise(Exception, 'error!')
17
+ when '/error' then raise(StandardError, 'error!')
18
18
  else
19
19
  [404, 'Nothing']
20
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arthur Chiu