Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

Where do we output exception messages from App_Code\MyClass.cs?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gnewsgroup - 21 Sep 2007 19:03 GMT
In a web application, we do not have access to the Console.

And quite often, in order to share a class across the entire web
application, we put it under App_Code.

Normally, classes placed under App_Code do not inherit
System.Web.UI.Page, and therefore do not have access to Response.Write
or any of our Web controls.

Nor do we have a console.

So, here is my question:  How do we handle exceptions thrown from, for
example, App_Code\MyClass.cs ?

Should we say something like below?

try
{
// blah blah
}
catch(SqlException se)
{
  throw new Exception(se.Message);
}

Thank you!
Phillip Williams - 21 Sep 2007 20:44 GMT
Re-throwing Exceptions is more expensive (on the performance of the
application) than letting the exception to propagate automatically.  So if
your class App_Code\MyClass.cs  does not do anything with a caught exception,
remove the try ... catch block from it and let the web page to handle it.

You might find this article helpful:  
http://msdn2.microsoft.com/en-us/library/ms954599.aspx#emag__exception_propagation
Signature

Regards,

Phillip Williams (MCPD Web Developer)
http://mcts-study-practices.com/
http://www.webswapp.com

> In a web application, we do not have access to the Console.
>
[quoted text clipped - 22 lines]
>
> Thank you!
gnewsgroup - 22 Sep 2007 05:01 GMT
On Sep 21, 3:44 pm, Phillip Williams <WEBSW...@newsgroups.nospam>
wrote:
> Re-throwing Exceptions is more expensive (on the performance of the
> application) than letting the exception to propagate automatically.  So if
[quoted text clipped - 33 lines]
>
> > Thank you!

OK, thank you very much.  I haven't been a good exception catcher.
But your idea helps clarify a major exception principle.  Thank you.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.