You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following #2471, I found that this case is raising an error.
describe'rescue Grape::Exceptions::ValidationErrors in json format with backtrace and original_exception'dolet(:app)doClass.new(Grape::API)doformat:jsonrescue_fromGrape::Exceptions::ValidationErrors,backtrace: true,original_exception: truedo |e|
error!(e,418,{},e.backtrace,e)endparamsdorequires:beerendget'/'doendendendbefore{get'/'}context'with json response type format'dosubject{last_response.status}it{is_expected.toeq(418)}endend
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.
The text was updated successfully, but these errors were encountered:
Unfortunately, since Grape::Exceptions::ValidationErrors generates an array when formatted in JSON, we won't be able to add the properties at the root level. Also, adding them to each element of the array might be to much.
Unfortunately, since Grape::Exceptions::ValidationErrors generates an array when formatted in JSON, we won't be able to add the properties at the root level. Also, adding them to each element of the array might be to much.
Agreed! And what if we could just skip the backtrace and the original exception filling if the message structure is not suitable for it? Something like #2480
Following #2471, I found that this case is raising an error.
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
andbacktrace
I think we'll need to enhance Grape::Exceptions::ValidationErrors with a new function to include its when dumping JSON.The text was updated successfully, but these errors were encountered: