I have the following code that returns the # of days in any given month, which works fine unless someone types in something that isn't a date, or they format the date wrong. To remedy this I want to send out an error message for an invalid input, but I don't know how. So how do I create an error message for this small app?
#type in the month and year you want like so ---> "Feb 2034"
require 'date'
input = gets.chomp
inputArray = input.split(" ").to_a
textMonth = inputArray[0]
textYear = inputArray[1]
startOfMonth = Date.strptime(input, "%b %Y")
nextMonth = startOfMonth.next_month
endOfMonth = nextMonth - 1
daysInMonth = (endOfMonth - startOfMonth + 1).to_i
puts "#{textMonth} of year #{textYear} has #{daysInMonth} days!"