Handling Exception Message (WM5.0)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,

What is the best practice for handling error messages in NET CF2.0
application? During development, System.SR.dll is preinstalled in the device
that returns detailed error messages which is useful for developer.

However, in actual product realease, System.SR.dll may not be present in end
user device. How should I deal with it? Should I include System.SR.cab in the
product installer or
provide custom message. For custom error message, how do indentify different
errors that might occur within an Exception class?

For instance, WebException could return the following error messages:

Could not establish connection to network.
Unable to connect to the remote server.


try
{
HttpWebRequest httpRequest =
(HttpWebRequest)HttpWebRequest.Create("http://my.com");
httpRequest.GetResponse();

}
catch(System.Net.WebException error)
{
//Could not establish connection to network.
//return custom message A

//Unable to connect to the remote server.
//return custom message B
}

How can i differentiate this two to return appropriate custom error messages
to user?
Pls advise.

Thanks.
 
Firstly, System.SR is provided for debugging only and you should not
distribute it with your finished applications.

To determine the cause of a WebException you can check a couple of
properties - firstly the Status which will will tell you the type of error -
connection failed, name resolution (DNS) failed etc. You can also look at
the Response and InnerException properties for more details.

Peter
 
Back
Top