public
Rubygem
Description: A very fast & simple Ruby web server
Homepage: http://code.macournoyer.com/thin/
Clone URL: git://github.com/macournoyer/thin.git
Click here to lend your support to: thin and make a donation at www.pledgie.com !
Rescue all types of errors when processing request
[#62 state:resolved]
macournoyer (author)
Fri Apr 18 19:38:06 -0700 2008
commit  a9acdec985583b0a9dd539417634b2c0eaee3b40
tree    ea57a017e9209cb4dfbc02feb884715c5e1e7e92
parent  79f2a3257732004d06131172359688202b0362aa
...
1
 
2
3
4
...
1
2
3
4
5
0
@@ -1,4 +1,5 @@
0
 == 0.8.1 Rebel Porpoise release
0
+ * [bug] Rescue all types of errors when processing request, fixes #62
0
  * [bug] Use Swiftiply backend when -y option is specified, fixes #63 and #64
0
  * Allow passing port as a string in Server.new
0
  * Define deferred?(env) in your Rack application to set if a request is handled in a
...
57
58
59
60
 
61
62
63
...
80
81
82
83
 
84
85
86
...
133
134
135
136
 
137
138
139
...
57
58
59
 
60
61
62
63
...
80
81
82
 
83
84
85
86
...
133
134
135
 
136
137
138
139
0
@@ -57,7 +57,7 @@ module Thin
0
       
0
       # Process the request calling the Rack adapter
0
       @app.call(@request.env)
0
-    rescue
0
+    rescue Object
0
       handle_error
0
       terminate_request
0
       nil # Signal to post_process that the request could not be processed
0
@@ -80,7 +80,7 @@ module Thin
0
       # If no more request on that same connection, we close it.
0
       close_connection_after_writing unless persistent?
0
       
0
-    rescue
0
+    rescue Object
0
       handle_error
0
     ensure
0
       terminate_request
0
@@ -133,7 +133,7 @@ module Thin
0
     # IP Address of the remote client.
0
     def remote_address
0
       @request.forwarded_for || socket_address
0
-    rescue
0
+    rescue Object
0
       log_error
0
       nil
0
     end
...
30
31
32
 
 
 
 
 
 
 
 
 
 
33
34
35
...
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
0
@@ -30,6 +30,16 @@ describe Connection do
0
     @connection.process
0
   end
0
   
0
+  it "should rescue error in process" do
0
+    @connection.app.should_receive(:call).and_raise(StandardError)
0
+    @connection.process
0
+  end
0
+  
0
+  it "should rescue Timeout error in process" do
0
+    @connection.app.should_receive(:call).and_raise(Timeout::Error.new("timeout error not rescued"))
0
+    @connection.process
0
+  end
0
+  
0
   it "should return HTTP_X_FORWARDED_FOR as remote_address" do
0
     @connection.request.env['HTTP_X_FORWARDED_FOR'] = '1.2.3.4'
0
     @connection.remote_address.should == '1.2.3.4'

Comments