Ruby 我如何处理Sinatra中的Mongoid错误?
可以在我的Sinatra应用程序中编写一个错误处理程序来处理来自Mongoid的错误吗?例如,我可以编写一个方法来处理来自Mongoid的DocumentNotFound异常吗?当然可以 在Sinatra中为Mongoid异常编写错误处理程序:Ruby 我如何处理Sinatra中的Mongoid错误?,ruby,sinatra,mongoid,Ruby,Sinatra,Mongoid,可以在我的Sinatra应用程序中编写一个错误处理程序来处理来自Mongoid的错误吗?例如,我可以编写一个方法来处理来自Mongoid的DocumentNotFound异常吗?当然可以 在Sinatra中为Mongoid异常编写错误处理程序: error Mongoid::Errors::DocumentNotFound do #pass the id's to the view haml :mongoiderror, :locals => { :ids => reques
error Mongoid::Errors::DocumentNotFound do
#pass the id's to the view
haml :mongoiderror, :locals => { :ids => request.env['sinatra.error'].identifiers }
end