From: Michael Guterl Date: 2007-12-10T06:56:11+09:00 Subject: Re: handle a special foramt error when importing csv ------=_Part_14256_26645019.1197237366701 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, On Dec 9, 2007 3:03 PM, Raimon Fs wrote: > hello, > > I have to import lots of csv files, and sometimes, there's one with the > .csv that is not quite good formatted, and Ruby send a: > > CSV::IllegalFormatError in DadeController#import_file_data_ajax > CSV::IllegalFormatError > > I'm trying to handle the error with > > begin > # Exceptions raised by this code will > # be caught by the following rescue clause > > ... some code ... > > > rescue Exception try this, rescue CSV::IllegalFormatError > $stderr.print "IO failed: " + $! > > ... some code ... > > raise > > > but the error/exception never raises ... > > I tried with SystemCAllError, StandardError, Exception, ... > > The error happens in: > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/csv.rb:639:in > `get_row' > > because the file hasn't the expected formatted, it's not a csv file, but > the file has an extension of csv, that's why I want to catch those > exceptions ... > > thanks, > > regards > > > raimon > -- > Posted via http://www.ruby-forum.com/. > HTH, Michael Guterl ------=_Part_14256_26645019.1197237366701--