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
Since #2468, error! signature has been aligned across different places. Unfortunately, even if you pass a backtrace and/or original_exception arguments, these latter won't be part of the returned message even if backtrace: true and/or original_exception: true are set at the rescue_from level.
Here are the specs
# jsoncontext'rescue_from include backtrace and original exception'dosubject{JSON.parse(last_response.body)}let(:app)doClass.new(Grape::API)doformat:jsonrescue_from:all,backtrace: true,original_exception: truedo |e|
error!(e.message,500,nil,e.backtrace,e)endparamsdorequires:param,type: Integerendget'/'do'it works'endendendbeforedoget'/'endit{is_expected.toinclude('error'=>a_kind_of(String),'backtrace'=>a_kind_of(Array),'original_exception'=>a_kind_of(String))}end#xmlcontext'rescue_from include backtrace and original exception'dosubject{Grape::Xml.parse(last_response.body)['error']}let(:app)doClass.new(Grape::API)doformat:xmlrescue_from:all,backtrace: true,original_exception: truedo |e|
error!(e.message,500,nil,e.backtrace,e)endparamsdorequires:param,type: Integerendget'/'do'it works'endendendbeforedoget'/'endit{is_expected.tohave_key('backtrace') & have_key('original-exception')}end#txtcontext'rescue_from include backtrace and original exception'dosubject{last_response.body}let(:app)doClass.new(Grape::API)doformat:txtrescue_from:all,backtrace: true,original_exception: truedo |e|
error!(e.message,500,nil,e.backtrace,e)endparamsdorequires:param,type: Integerendget'/'do'it works'endendendbeforedoget'/'endit{is_expected.toinclude('backtrace','original exception')}end
Although if we specify backtrace: true and/or original_exception: true and pass the original exception as message like
It will break with an exception when format is json
# exception# NoMethodError:# undefined method `merge' for an instance of Grape::Exceptions::ValidationErrors# ./lib/grape/error_formatter/json.rb:13:in `call'# ./lib/grape/middleware/error.rb:49:in `format_message'context'rescue_from include backtrace and original exception'dosubject{JSON.parse(last_response.body)}let(:app)doClass.new(Grape::API)doformat:jsonrescue_from:all,original_exception: true,backtrace: truedo |e|
error!(e,500,nil,e.backtrace,e)endparamsdorequires:param,type: Integerendget'/'do'it works'endendendbeforedoget'/'endit{is_expected.toinclude('error'=>a_kind_of(String),'backtrace'=>a_kind_of(Array),'original_exception'=>a_kind_of(String))}end
The text was updated successfully, but these errors were encountered:
Since #2468,
error!
signature has been aligned across different places. Unfortunately, even if you pass abacktrace
and/ororiginal_exception
arguments, these latter won't be part of the returned message even ifbacktrace: true
and/ororiginal_exception: true
are set at therescue_from
level.Here are the specs
Although if we specify
backtrace: true
and/ororiginal_exception: true
and pass the original exception as message likeIt will break with an exception when format is json
The text was updated successfully, but these errors were encountered: