Good Error Messages Point the Way
By chris on May 31st 2008 in /dev/random | 456 views
Ran into an odd error today, the result of this line in a library I’m using:
raise '@level is blank. Did you override the allow_to method in your controller?' if @level.blank?
A quick check of my code and “err no, I don’t think so. Should I?”
Yes I should, and in that then call super() to initialize @level. So I rewrote the error message in that lib to read as the following, because I know it’s going to bite me again some time:
raise '@level is blank. Did you override the allow_to method in your controller? You should, and call super() from within it.' if @level.blank?
Bad error messages throw up an error number. Mediocre ones hint at the problem. Good error messages point the way to a solution.