如何找出方法可以抛出哪种异常?

Dav*_*Dev 5 .net c# exception-handling exception

我正在编写调用以下方法的代码 Windows.Networking.PushNotifications

// Summary:
//     Creates objects that you use to retrieve push notification channels from
//     the Windows Push Notification Services (WNS). These channels are bound to
//     an app or secondary tile.
[Threading(ThreadingModel.MTA)]
[Version(100794368)]
public static class PushNotificationChannelManager
{
    // Summary:
    //     Creates an object, bound to the calling app, through which you retrieve a
    //     push notification channel from Windows Push Notification Services (WNS).
    //
    // Returns:
    //     The object, bound to the calling app, that is used to request a PushNotificationChannel
    //     from the Windows Push Notification Services (WNS).
    [Overload("CreatePushNotificationChannelForApplicationAsync")]
    public static IAsyncOperation<PushNotificationChannel> CreatePushNotificationChannelForApplicationAsync();

}
Run Code Online (Sandbox Code Playgroud)

我想确保涵盖所有可以抛出异常的情况并适当地处理每个情况.我是否有可能获得可能引发的不同类型的异常列表以及可能导致它们的不同情况?

我不想只是抓住一切

catch(Exception ex) { }    
Run Code Online (Sandbox Code Playgroud)

此MSDN文章指出"如果您在没有数据连接时尝试注册WNS推送通知通道,则会引发异常".但是,它没有说明什么类型的异常,或者是否存在可以抛出异常的其他情况.

如何确定是否存在其他可能的异常类型?

Ham*_*jam 4

唯一的方法是文档和源代码,尽管请注意可能会抛出许多其他异常,例如OutOfMemoryException、和 ... 因此,我认为正确的方法是捕获异常,您可以对它们做一些处理,并TypeLoadExceptionThreadAbortException其他人冒泡调用堆。

另请阅读此令人烦恼的异常