File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -1942,6 +1942,26 @@ def foo
1942
1942
expect { get '/unrescued' } . to raise_error ( RuntimeError , 'beefcake' )
1943
1943
end
1944
1944
1945
+ it 'mimics default ruby "rescue" handler' do
1946
+ # The exception is matched to the rescue starting at the top, and matches only once
1947
+
1948
+ subject . rescue_from ArgumentError do |e |
1949
+ error! ( e , 402 )
1950
+ end
1951
+ subject . rescue_from StandardError do |e |
1952
+ error! ( e , 401 )
1953
+ end
1954
+
1955
+ subject . get ( '/child_of_standard_error' ) { raise ArgumentError }
1956
+ subject . get ( '/standard_error' ) { raise StandardError }
1957
+
1958
+ get '/child_of_standard_error'
1959
+ expect ( last_response . status ) . to eql 402
1960
+
1961
+ get '/standard_error'
1962
+ expect ( last_response . status ) . to eql 401
1963
+ end
1964
+
1945
1965
context 'CustomError subclass of Grape::Exceptions::Base' do
1946
1966
before do
1947
1967
module ApiSpec
You can’t perform that action at this time.
0 commit comments