public
Fork of bmizerany/sinatra
Description: Classy web-development dressed in a DSL
Homepage: http://sinatrarb.com
Clone URL: git://github.com/JackDanger/sinatra.git
raise errors from error

This allows us to test custom errors easier
Blake Mizerany (author)
Tue Apr 01 13:38:36 -0700 2008
commit  0eca3f46c74bfc88fb97484fc6f1744f1cfbe79a
tree    9d3a38e3b7020cf001bb54b8ebde8797d1c70eb0
parent  be5f5270ec642be3e17e7b739dc4c3e06464fff4
...
738
739
740
741
742
743
744
...
763
764
765
766
 
 
 
 
767
768
769
...
738
739
740
 
741
742
743
...
762
763
764
 
765
766
767
768
769
770
771
0
@@ -738,7 +738,6 @@ module Sinatra
0
         end
0
         body = returned.to_result(context)
0
       rescue => e
0
- raise e if options.raise_errors
0
         request.env['sinatra.error'] = e
0
         context.status(500)
0
         result = (errors[e.class] || errors[ServerError]).invoke(request)
0
@@ -763,7 +762,10 @@ module Sinatra
0
     
0
     def setup!
0
       configure do
0
- error { '<h1>Internal Server Error</h1>'}
0
+ error do
0
+ raise request.env['sinatra.error'] if Sinatra.options.raise_errors
0
+ '<h1>Internal Server Error</h1>'
0
+ end
0
         not_found { '<h1>Not Found</h1>'}
0
       end
0
       
...
46
47
48
 
 
 
 
 
 
 
 
 
 
 
 
49
50
51
...
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
0
@@ -46,6 +46,18 @@ context "Custom Errors (in general)" do
0
     
0
     Sinatra.application.options.raise_errors = true
0
   end
0
+
0
+ class UnmappedError < RuntimeError; end
0
+
0
+ specify "should bring unmapped error back to the top" do
0
+ get '/' do
0
+ raise UnmappedError, 'test'
0
+ end
0
+
0
+ assert_raises(UnmappedError) do
0
+ get_it '/'
0
+ end
0
+ end
0
 
0
 end
0
 
...
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
6
7
8
 
9
10
 
 
 
 
 
11
12
13
0
@@ -6,14 +6,8 @@ context "Mapped errors" do
0
   
0
   setup do
0
     Sinatra.application = nil
0
- Sinatra.application.options.raise_errors = false
0
   end
0
   
0
- teardown do
0
- Sinatra.application.options.raise_errors = true
0
- end
0
-
0
-
0
   specify "are rescued and run in context" do
0
     
0
     error FooError do

Comments

    No one has commented yet.