I'm writing a C# library, whose DLL will be later used by code of other application(s).
When there is a statement in the library that could throw an exception such as System.IO.IOException, should I catch it then and there itself or should I leave it to be caught by the program of the application that uses it?
I ask this because, I have not caught the exception in my library. When debugging my application (that uses the library), Visual Studio shows it to me as an unhandled exception in the library. But when I > Continue, the program continues and the exception is caught by the application. It seems to be working fine.
Now, is it okay to do this - i.e., could there be any problems when the application is deployed? Or should it be absolutely caught in the library itself? Or does MSDN suggest somewhere, something better than this as a "best practice"?
Aucun commentaire:
Enregistrer un commentaire