Forums | Admin

Discussion Forums: open-discussion

Start New Thread Start New Thread

 

By: Moses Hohman
RE: FasterCSV#shift swallows exceptions [ reply ]  
2010-02-06 17:42
Wonderful! Thanks, have a nice weekend,

Moses

By: James Gray
RE: FasterCSV#shift swallows exceptions [ reply ]  
2010-02-05 23:55
Your logic sounds good to me. I've checked your change into git:

http://github.com/JEG2/faster_csv

Thanks!

By: Moses Hohman
FasterCSV#shift swallows exceptions [ reply ]  
2010-02-05 23:18
Hi James,

Thanks for writing FasterCSV, I've gotten a lot of benefit out of it.

One thing continues to bug me about it, and I thought I'd ask whether it was intentional. In FasterCSV#shift at the beginning of the loop, you have:

begin
line += @io.gets(@row_sep)
rescue
return nil
end

i.e. you swallow any exception that might occur and just return nil. There are cases where I want to know what that exception was, but I have no opportunity.

I would suggest you change this to:

if read_line = @io.gets(@row_sep)
line += read_line
else
return nil
end

All of your tests still pass with that code, except for one that had a small error in it (hidden by the exception swallowing), tc_interface.rb's test_write_hash should open the csv for reading the second time...

Hope this is helpful,

Moses