How do you handle errors ocurring throughout your application?
I have this example, say a user is trying to view a product that does not exist: The user makes a query to view a product with id = 1 and there is no product in the database with that id. A ActiveRecord::RecordNotFound exception is thrown.
Now what do i do?
Should i have a specific controller which i pass all errors to be taken care of. Or should i handle the error in the current controller and action?
Then it comes to my mind that this is one type of problem which maybe should be handled one way. On the other side, user input in forms that are not valid is one type of error and maybe should be handled in another way?
I just want some thoughts about this, and how you design your app.
if you use dynamic finders they dont error when nothing is found with your query. Kiek this:
Say your model is User and you want to find by the id in the params:
@user = User.find_by_id(params[:id])
That will work without throwing an error if your find returnjs nil.