Closed
Description
Following #2471, I found that this case is raising an error.
describe 'rescue Grape::Exceptions::ValidationErrors in json format with backtrace and original_exception' do
let(:app) do
Class.new(Grape::API) do
format :json
rescue_from Grape::Exceptions::ValidationErrors, backtrace: true, original_exception: true do |e|
error!(e, 418, {}, e.backtrace, e)
end
params do
requires :beer
end
get '/' do
end
end
end
before { get '/' }
context 'with json response type format' do
subject { last_response.status }
it { is_expected.to eq(418) }
end
end
Our README shows the same kind of example but without original_exception and backtrace.
Nonetheless, It works for XML and TXT because of the simple ternary condition while JSON is doing something different when Grape::Exceptions::ValidationErrors
If we want to add original_exception
and backtrace
I think we'll need to enhance Grape::Exceptions::ValidationErrors with a new function to include its when dumping JSON.
Metadata
Metadata
Assignees
Labels
No labels