int re = 0;
try
{
// 尝试执行以下代码块
// 如果在执行过程中发生异常,则立即跳转到catch块
// Run each tool using the RunTool function
foreach(ICogTool tool in mToolBlock.Tools)
mToolBlock.RunTool(tool, ref message, ref result);
}
catch(Exception)
{
// 当try块中的代码发生异常时,执行这里的代码
// Exception参数代表捕获的异常对象
re = 1;
}
//调用re的结果对工具 运行异常进行处理
switch (re)
{
case 0:
//工具运行正常
break;
case 1:
//工具错误
break;
}