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
Ignacio Machin ( .NET/ C# MVP ) - 28 Mar 2008 20:06 GMT
On Mar 28, 11:29 am, raulavi <raul...@discussions.microsoft.com>
wrote:
> vs2005 C#
>
[quoted text clipped - 24 lines]
>
> Thanks
You should better check for those cases and do something if
appropiated.
Of course you can always catch Exception and be done with it :)