botanicus / rango

Rango is ultralightweight, ultracustomizable, ultracool web framework inspired by Django.
http://101ideas.cz
MIT License
221 stars 9 forks source link

Map each ORM exceptions to Rango HTTP errors #141

Open botanicus opened 14 years ago

botanicus commented 14 years ago
quiet do
  DataMapper::ObjectNotFoundError = Class.new(NotFound)
end

So you rather than:

def show(id)
  post = Post.get(id)
  raise NotFound unless post
  render "post.html", post: post
end

use just:

def show(id)
  render "post.html", post: Post.get!(id)
end

Where should I put it? Generate it to the beginning of models? Somewhere to lib/rango/orm?