Tuesday, May 19, 2009

Relying on error messages in your application logic

This is a very simple thing but it makes lot of difference for the developers especially the new comers. When we dive deep into our applications/programs to deliver functionality, at times few developers rely on standard error messages thrown by .NET for example. For example, let’s say that you are trying to read a file (which is not present) using .NET base class library. You will get FileNotFound exception. In this case if you have written logic in your application in such a way that if error message is XYZ then do this. This may work with the current version of framework which you are using. However, in future if you install any hot fix or the newer version of .NET framework, the error message may not be the same. The error code may remain same but not the error message.

In simple words, do not rely on standard error messages in your application logic.

Cheers,
Amol

No comments: