问题描述
我正在用C#编写一个小程序,在该程序中,我有一个基本错误类,该类继承自System.Exception
类。看起来如下
// Simple Error class,used for inheriting to other types of errors
public class Error : Exception {
public Error(string ErrorType,string ErrorValue) {
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine($"[{ErrorType}]");
Console.ResetColor();
Console.WriteLine($"\t{ErrorValue}");
}
}
问题是,我从基类Exception
继承,因此我可以throw
对象。 投掷 时,它会按预期进行。我唯一想知道的是;如果有办法使异常部分本身不打印。也就是说,自“抛出异常”以来出现的那个
Unhandled Exception: <program-name>.Error: Exception of type '<program-name>.Error' was thrown.
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)