displaying exception message from custom exception

B

bdgreen

Hi,

I made a custom exception, derived from ApplicationException. If the
exception is thrown, the erroring web page shows the line of code where
I throw exception, and doesn't display the exception message. Do I
need to catch my custom exception, and rethrow it as another type of
exception to make the message display?

I still want to page to error out, I don't want to catch it and return
a user-friendly message or anything. The page needs to error so that
operations will know errors are being thrown.

Thanks
 
S

sloan

see
http://www.aspnetresources.com/blog/custom_exception_class.aspx



What I do is this.. which isn't what you want.

try

{

// web page stuff

}

catch(Exception ex)
{
Response.Write (ex.Message);
// or this
/*
if(null!=ex.InnerExeption)
{
Response.Write(ex.InnerException.Message);
}
*/
}


Ok.. having said that.. then yeah. do this.

try
{
//web stuff
}

catch(MyNamespace.MyException mex)
{
throw new SuperFriendlyException("MyException was thrown, but I don't
want to show you its info");
}
catch(Exception ex)
{
throw new SuperFriendlyException("ex was thrown, but I don't want to
show you its info");
}

Something like that.

Note, MyException is not the same object as SuperFriendlyException
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top