如何捕获抛出的异常
我在一个类里catch里throw e 了一个错误,我怎么才可以在调用这个类的地方捕获这个异常呢?
谢谢
------解决方案--------------------protected void button1_click(object sender,EventArgs e)
{
try
{
aaa();
}
catch(Exception e)
{
Response.write(e.Message);
}
}
private void aaa()
{
throw new Exception( "这个异常是从aaa里抛出的. ")
}
------解决方案--------------------try
{
Callyourmethod();//maybe throw exception
}
catch(Excepion ex)
{
//if Callyourmethod() throw Exception,you can catch at here
do something here;
}
------解决方案--------------------看书去~