Skip to content

Game: De mystify Error Messages

Pat Maddox edited this page Jul 6, 2015 · 2 revisions

Exercepted from RubySteps: The Playbook


Game: De-mystify Error Messages

You've typed in your code, predicted the future, run it... and get an error. That's programming for you. What do you do now? Google? Stack Overflow? Give up? There has to be a better way...

To be a successful bug collector, you must understand one thing: Ruby error messages give you all of the information you need. Only one question remains: will you use the valuable information that Ruby is telling you?

Write down the error class, line number, target object, and message in separate comments. If you don't understand why the error happens, search for the class on RubyDocs and read the description. Most error messages in Ruby only need one sentence of explanation. Make a change and predict the future.

To solidify your understanding of this type of error message, intentionally create the same kind of error in another part of your code.

If you do nothing else in this book, DO THIS. Break your dependence on Google. Read official documentation. Seriously.