Better_Errors: A Lifesaver!
As developers, we rely on error messages to help guide us as to what aspects of our applications need more attention when things don’t go as expected. Ruby, more than many other programming languages, provides users with detailed error messages that attempt to pinpoint the actual source driving the error. However, there are times when even Ruby’s native error message system can be a bit misleading. As our applications become larger and more complex, a simple misleading application error message can easily lead to hours of wasted time searching for and changing the wrong lines of code. Intro “Better_Errors.”
Better Errors is a Rails gem that the Railsgem repository describes as a gem that “ …replaces the standard Rails error page with a much better and more useful error page….” In practice, I found this gem extremely helpful. For example, I intentionally left off an ‘end’ tag in a blog application that I was building in rails and this was the error message that the native Rails gem threw me:

Obviously, since I made the coding error on purpose, I knew that this error message was not what was actually causing the issue. This is where the beauty of the Better_Errors come into play. Once activated, I then refreshed the application and this was the error message that I received:

Talk about spot on! Not only did the Better Errors gem tell me exactly what was wrong, but it also let me know exactly what file the error could be found in. AMAZING.

Installation
So now that we know we want Better Errors, the next step is to get it installed. Luckily , that’s super simple as well. Simply visit the RubyGems repository and type in “Better_Errors”. Click on the link with the most downloads(Currently about 22mm) and then just copy and paste the code into your gem file and then bundle install. Be sure to place the code in the development section of your gemfile, or it may not work. It’s as simple as that and then you too will have Better Errors.

Enjoy!
