Last post Apr 27, 2010 04:26 PM by atconway
Apr 27, 2010 01:25 PM|vmhatup|LINK
Even though I'm trying to implement exception handling in a multi-tiered Windows application, catching and throwing exceptions should be the same for Windows and Web (sans global.asax and web.config custom errors).
I have a webform with a texbox that displays exceptions. So my webform invokes a method in BusinessTier class which then invokes a method in DataTier class. How can I throw my DataTier method exception so it reaches my webform?
c# asp.net c sharp exception handling multi-tiered try catch
Apr 27, 2010 02:15 PM|qwe123kids|LINK
u can use "ApplicationException"
chk the above link for more info
Apr 27, 2010 04:26 PM|atconway|LINK
How can I throw my DataTier method exception so it reaches my webform?
One mis conception is that exceptions will not bubble up unless explicitly thrown; this is not true. Your generated exception should and will automatically bubble up From the DataTier -> to the BusinessTier -> to the webform (UI) unless handled and consumed
beforehand. No 'Throw()' statements are needed, and in fact they will disrupt the StackTrace if improperly used.
Try it out: generate or cause an exception at your lowest layer, and place only a 'Catch' at your highest layer (UI) with a break point set up. Sure enough the exception will bubble all the way back up automatically.