访问rescue_from中的参数

Bot*_*oti 1 rack ruby-on-rails ruby-grape

我正在使用葡萄,我想访问rescue_from中的请求参数:

class API < Grape::API

  rescue_from Grape::Exceptions::ValidationErrors do |e|
    rack_response({
  end
...
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

Bot*_*oti 5

我设法做到了这一点:

rescue_from :all do |e|
  req = Rack::Request.new(env)
  ApiCallAudits.create data: {input_params: req.params.as_json}, backtrace: $!.to_s, status: :error
end
Run Code Online (Sandbox Code Playgroud)