Re: catch (Exception e)



Hi,


Thanks for the quick replies...

Am Dienstag, den 24.10.2006, 20:16 +0200 schrieb Daniel Naber:
> On Tuesday 24 October 2006 15:44, Max wrote:
> 
> > Is there any reason for always putting the e or the ex variables there
> > even though they are not used afterwards?
> 
> The better question might be: why isn't it used? Even if you don't know 
> what to do and just log the exception it should print the exact cause of 
> the problem.

Quite often you know why a exception will probably be thrown and that it
does not indicate a problem. I was not explaining my self clear enough.
i was referring to some cases in beagle like this one
(BeagleClient/Indexable.cs, Line 287 following):

	try {
		File.Delete (contentUri.LocalPath);
	} catch (Exception ex)
	{ 
		// It might be gone already, so catch the exception.
	}

Imho it would be best to catch that exception like this:
	} catch (FileNotFoundException)
	{ 
		// It might be gone already, so catch the exception.
	}
	
This would also avoid catching other exceptions, that indicate a
different problem.


Max





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]