By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,682 Members | 1,387 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,682 IT Pros & Developers. It's quick & easy.

Exceptions in classes

P: n/a
I'm wondering what the best way to pass an exception up to an aspx page (for
example) from my object is.

If I have a method in my class

public function Test() as string

try

catch eEx as exception

end try

end function

In my aspx page:

dim myObj as new TestObject()

dim strString as string = myObj.Test

I guess what I'm wondering is the best way to handle an exception that may
occur in my TestObject class in my aspx page.

I hope that made sense,

Jason MacKenzie

Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Ok, catch and deal with the

exception if you can. In this

case you can return from

your method and the ASP page will never know.

If you can't resolve the problem (because it is more than the method/class
responsibilities) you could re-throw the exception and catch it at your
page.

In some circumstances you should treat as you can and throw a "custom"
exception object, to make the caller more capable to deal with it.
"Jason MacKenzie" <jm***************@formet.com> escreveu na mensagem
news:uA*************@tk2msftngp13.phx.gbl...
I'm wondering what the best way to pass an exception up to an aspx page (for example) from my object is.

If I have a method in my class

public function Test() as string

try

catch eEx as exception

end try

end function

In my aspx page:

dim myObj as new TestObject()

dim strString as string = myObj.Test

I guess what I'm wondering is the best way to handle an exception that may
occur in my TestObject class in my aspx page.

I hope that made sense,

Jason MacKenzie

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.