I write requires
,like this
params do
requires :user_id, :type => Integer
optional :page, :type => Integer, :default => 1
optional :per_page, :type => Integer, :default => 20
end
and I have wrote rescue_from
rescue_from :all do |e|
case e
when Grape::Exceptions::ValidationErrors
error!({ messages: e.full_messages }, 400)
else
Rails.logger.error "Api Error: #{e}"
Rails.logger.error "#{e.backtrace.join("\n")}"
error!({ messages: "errors" }, 500)
end
end
but I cannot catch Grape::Exceptions::ValidationErrors
without params[:user_id]