If we are using components in our application, how can we handle exceptions raised in a component
Loading
If we are using components in our application, how can we handle exceptions raised in a component
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Amit DhaniaPosted Jan 20, 2009, 7:30 AM
When we use components in our application, exceptions not handled at each component but at a specific section. Exception
occurred at component is thrown to next layer to next and finaly handled.
We handle exception in following in ways:
Create a class called MyException inheriting Exception class
public class MyException:Exception
{
public MyException(string msg)
: base(msg)
{
}
}
We wil use above class to handle exception flow from components to fnal layer we handle exception
Layer 3:
try{}
catch(exception ex){ throw MyException(ex.tosting());}
Layer 2:
try{}
catch(exception ex){ throw MyException(ex.tosting());}
Layer 1:
try{}
catch(exception ex){ //error handled here by creating errorlog or insert error details to database}
Scott LyslePosted Jan 10, 2009, 4:29 PM