twatter.rb
# We print and log an error with this method
We print and log an error with this method
We print and log an error with this method
def handle_error(error_message, handle = "")
  if handle == ""
    handle = "Your pattern"
  else
    handle = "@" + handle
  end
  if error_message == "!ts!"
    @invalid_count += 1
    error = "#{handle} is too short. Since 2015 new handles have to be > 4 chars."
  elsif error_message == "!tl!"
    @invalid_count += 1
    error = "#{handle} is too long. Maximum length is 15 characters (not inc @)."
  else
    line_length = error_message.length
    if line_length > 65
      line_length = 65
    end
    error = "="*line_length+"\n"
    error += "ERROR: " + error_message+"\n"
    error += "="*line_length+"\n"
    @unknown_errors += 1
    log('both',error)
    return "\n"+error
  end
end
def handle_error ( error_message , handle = "" ) if handle == "" handle = "Your pattern" else handle = "@" + handle end if error_message == "!ts!" @invalid_count += 1 error = "#{handle} is too short. Since 2015 new handles have to be > 4 chars." elsif error_message == "!tl!" @invalid_count += 1 error = "#{handle} is too long. Maximum length is 15 characters (not inc @)." else line_length = error_message . length if line_length > 65 line_length = 65 end error = "=" * line_length + "\n" error += "ERROR: " + error_message + "\n" error += "=" * line_length + "\n" @unknown_errors += 1 log ( 'both' , error ) return "\n" + error end end
We print and log an error with this method
We print and log an error with this method
# We call this error from two places, once when checking the pattern length # and again as we check each option.
error_message
<not_specific>
handle
<not_specific>