【发布时间】:2009-03-21 14:34:49
【问题描述】:
我正在为 CLR 脚本编写 .NET On-the-Fly 编译器。并且有一个两难选择:在构建失败时抛出异常是否更好?
那么最佳实践观点是什么,哪种方法更合适?
try
{
compiler.Compile(); // do not throws an exception only if build succeed
}
catch(CompilerException ex)
{
string err = ex.Message;
}
或
compiler.Compile(); // throws an exception only in case of crash, etc
if(!compiler.BuildSucceed)
{
string err = compiler.Output.ToString();
}
【问题讨论】:
标签: .net exception architecture