我有一个名为“网站”的类,在该类中我有以下属性:
public HtmlForm RegisterForm
{
get
{
if (Forms.RegForm != null) / Forms is a custom object called HTMLForms that is a custom list collection
{
return Forms.RegForm;
}
else
{
// FindPageWithGoogle Google = new FindPageWithGoogle();
// use Google.FindRegistrationForm(this.currentUrl) method
//throw new Exception(); // if registration form object can't be found
}
return Forms.RegForm;
}
}
这会是处理错误的有效方法吗?如果找不到它,如果抛出此异常,我将如何停止程序的整个流程?我知道如何使用简单的 try catch,但我认为这还不够。我相信我需要学习如何制作自己的自定义异常处理系统来相应地处理这些自定义事件。
谢谢你的帮助。此外,如果您有一本关于异常处理的特定书籍,因为我到目前为止阅读的 C# 书籍并没有深入探讨该主题,因此将不胜感激。
谢谢,
科迪