R
raulavi
vs2005 C#
How many exceptions should I trap when reading a file ?
let me clarify...
c is my pointer to the processing line
I have this code:
public int ProcessFile(string[] file, int c)
{
if (c < file.Length && line.IsSegment(file[c]))
...
1. if file is null a reference to file c < file.Length will crash.
2. 5 lines on file and c index does not point to the rigth line (migth be
-10) crash.
3. file has 5 lines: when checking file.length c could have -1 (will pass)
but line.IsSegment(file[c])) will crash, correct?
is it good to use try-catch ?
then, there is no way to know whats going on .
file or index (or what else??)
am i missing any other exceptions?
Thanks
How many exceptions should I trap when reading a file ?
let me clarify...
c is my pointer to the processing line
I have this code:
public int ProcessFile(string[] file, int c)
{
if (c < file.Length && line.IsSegment(file[c]))
...
1. if file is null a reference to file c < file.Length will crash.
2. 5 lines on file and c index does not point to the rigth line (migth be
-10) crash.
3. file has 5 lines: when checking file.length c could have -1 (will pass)
but line.IsSegment(file[c])) will crash, correct?
is it good to use try-catch ?
then, there is no way to know whats going on .
file or index (or what else??)
am i missing any other exceptions?
Thanks