For Programmers: Free Programming Magazines  


Home > Archive > Microsoft Webservices > April 2006 > What is the best way of displaying SoapException?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author What is the best way of displaying SoapException?
Stan

2006-04-07, 7:06 pm

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


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com