Exceptions happen. There's no way around that. But not all exceptions are created equally.
For instance, a 404 "Not found" error can (and should) be handled correctly in your application.
Let me give you an example of how to handle a `ActiveRecord::RecordNotFound` exception. Let's assume you have an application that could show a user profile:
Now, it may happen that the `:name` paramater contains a value that cannot be found in our database, most likely because someone made a typo in the URL.
If `Profile#find` cannot get a proper result it will throw `ActiveRecord::RecordNotFound`.
Now, instead of showing the user the (by default ugly) 404 page from `public/404.html` we want to do something more fancy.
Whenever an `ActiveRecord::RecordNotFound` exception is thrown (and not handled by the action itself), it will be handled by your `ApplicationController`.
## Custom exceptions
It's possible to throw your own custom exceptions and handle them in different ways. Like this: