I'm writing a program to validate CSV files in Ruby but I seem to not be using rescue correctly. I made sure to include the begin keyword. I'm using ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]
The code is here:
def self.validate
begin
CSV.foreach(@@filepath, headers: true) do |row|
rescue CSV::MalformedCSVError
return row
end
return -1
end
It's probably something silly, but I'm not sure what as I have the begin keyword included.