Displaying 1 result from an estimated 1 matches for "unknownproduct".
2007 Jul 31
2
controller exceptions
...es in Merb
could be a cute way to approach error handling.
Suppose one has an action for editing a product which you would like
to restrict to administrators:
def edit
raise AdminAccessReqired unless session[:user] and session[:user].admin?
@product = Product.find(params[:id])
raise UnknownProduct if @product.nil?
render
end
Where AdminAccessReqired and UnknownProduct are ControllerExceptions.
The controller exception hierarchy would be rooted with the base
class, Merb::ControllerException. The Merb dispatcher would rescue any
exception which was a kind_of ControllerException. Derive...