ad,
You catch objects of type Exception, which means you handle all exceptions
in the same place. My suggestion is to filter down the exception that you
expect to be thrown by type. then in the event handlers instead
error(e.Message) you can emit most friently message.
try
{
}
catch(ExceptionType1 e1)
{
error("message1");
}
catch(ExceptionType2 e1)
{
error("message2");
}
catch(ExceptionType3 e1)
{
error("message3");
}
catch(Exception e)
{
// for unexpected exceptions you can show the original message or some
message in the line of the "unexpected error"
error(e.Message);
}
You have to always start from the more specific to the common exception
types. If you put catch(Exception e) as a first exception block it will
catch all the exception and the execution will never enter the other blocks.
HTH
Stoitcho Goutsev (100) [C# MVP]
"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
I use try..catch(exception e) to catch excption and show to
error(e.Message)
to user.
But the error is some difficult for user to understand.
How can I change the e.Message to some custom message.