|
| When SoapException is thrown, the Message property looks like that:
....
System.Web.Services.Protocols.SoapException: Server was unable to process
request. ---> System.ApplicationException: Account 3333344 is invalid\n
......
followed by 500 or so bytes of other info.
What I want to show the user is "Account 3333344".
Yes, I can do something like:
........
public static void DisplayError(System.Web.Services.Protocols.SoapException
ex)
{
string ScrabbedMsg;
string msg = ex.Message;
int PosStart = msg.IndexOf("-->");
int PosEnd = msg.IndexOf("Server stack trace");
if ((PosEnd - PosStart) > 0)
ScrabbedMsg = msg.Substring(PosStart + 3, PosEnd -
PosStart - 3);
else
ScrabbedMsg = msg;
MessageBox.Show(ScrabbedMsg);
}
.............................
But I don't really like it...
Exception is thrown on a server with:
..................
throw new ApplicationException(string.Format("Account {0} is invalid",
AccountNumber));
..................
Why cannot I simply get my inner ApplicationException out of SoapException
on the client, without going through these string parsing exercises?
Thanks,
-Stan
|
|