Skip to content

Commit 9a551b1

Browse files
committed
Add spec with calling error! helper inside the rescue_from block
1 parent b47d9ad commit 9a551b1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

spec/grape/api_spec.rb

+12
Original file line numberDiff line numberDiff line change
@@ -2532,6 +2532,18 @@ def self.call(message, _backtrace, _options, _env, _original_exception)
25322532
get '/exception'
25332533
expect(last_response.body).to eq('message: rain! @backtrace')
25342534
end
2535+
2536+
it 'returns a modified error with a custom error format' do
2537+
subject.rescue_from :all, backtrace: true do |e|
2538+
error!('raining dogs and cats', 418, {}, e.backtrace, e)
2539+
end
2540+
subject.error_formatter :txt, with: custom_error_formatter
2541+
subject.get '/exception' do
2542+
raise 'rain!'
2543+
end
2544+
get '/exception'
2545+
expect(last_response.body).to eq('message: raining dogs and cats @backtrace')
2546+
end
25352547
end
25362548

25372549
it 'rescues all errors and return :json' do

0 commit comments

Comments
 (0)