January 23rd, 2012, 10:21 PM
I'm building an error handler by a book and I think it's not working as it should. According to the book, the code should output only 2 lines (wording is a bit different, I know):
but I get only the first line, followed by, I guess actual errors in my error handler. Here's the console text:
Here's the code itself:
I spent an hour now looking at this code, trying to figure out the error with no results... Can anyone help?
class GenderError < RuntimeError
@what_they_put = their_input
if (gender.upcase != 'FEMALE') && (gender.upcase != 'MALE')
raise GenderError.new(gender), "What's this? Invalid input?"
rescue GenderError => e
puts "incorrect input value: " + e.what_they_put
dude = Person.new("fuzzy")