July 2016
Intermediate to advanced
150 pages
4h 24m
English
By default, the Rollbar client will report any uncaught exception. But you can also report exceptions and other types of events manually.
For example, you may want to trap an exception, report it, and then proceed with some default logic. In Twitalytics, this is necessary when a nonexistent post is requested. Open the app/controllers/posts_controller.rb file, and find the set_post method. Modify it to look like this:
| | def set_post |
| | @post = Post.find(params[:id]) |
| | rescue ActiveRecord::RecordNotFound => e |
| | Rollbar.error(e, "Requested an unknown Post") |
| | Rollbar.log("Defaulting to first Post") |
| | @post = Post.first |
| | end |
The rescue clause calls Rollbar.error if an ActiveRecord::RecordNotFound is raised. ...
Read now
Unlock full access