Closed yakra closed 6 years ago
try
blocks:
How would indentation etc. compare with current committed version?
How would the DIFFs look?
No need to return 0 or terminate program, etc. Just skip adding element to vector/deque and continue
• [] > string length causes undefined behavior; use string::at
This makes no difference. string::at would throw an exception even at the end of a good line when attempting to evaluate whether CSVline[i] != ';'
. The solution is to check whether i < CSVline.size()
, which renders the distinction between [] and .at() moot.
Test with: • NY I-90 ... Just skip adding element to vector/deque and continue
This is exactly what happens when reading a Chopped Routes CSV. After premature end of a CSV line, nothing gets pushed to the strings it's split into. Thus it tries to look for a file named .wpt
, (most likely) doesn't find it, and life goes on. If it does find such a file, I'm not going to code for such a rare case. Don't leave those lying around.
No changes are needed here, other than adding in a bit of i < CSVline.size()
to the IF statements.
On second thought, this is easy. Done. Tests if (Root.empty())
.
• break usact's systems.csv line
Incomplete CSVline -> garbage data after end -> wacky hijinks. In this case, usact ended up being rendered in lightsalmon.
i < CSVline.size()
definitely needed here too.
...An empty Tier field can cause unsigned short Tier = stoi(TierS);
to throw std::invalid_argument
.
This is where try and catch come in.
http://www.cplusplus.com/reference/string/string/operator[]/ http://www.cplusplus.com/reference/string/string/at/ http://www.cplusplus.com/reference/stdexcept/out_of_range/
canvas & gisplunge • Test a broken CSV with incomplete information • [] > string length causes undefined behavior; use string::at • Test broken CSV again • try, catch
Test with: • NY I-90 • break usact's systems.csv line