如何确定异常类型? [英] How to Determine the Type of Exception?

查看:103
本文介绍了如何确定异常类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好

 

在Visual C ++ 2008中调试程序时,我得到一个异常说"Microsoft C ++异常:COleDispatchException在内存位置0x ####"。根据这些信息,我添加了一个try-catch块,如下所示:

When debugging program in Visual C++ 2008, I get an exception said "Microsoft C++ exception: COleDispatchException at memory location 0x####". Based on this info, I add a try-catch block as follows:

 

尝试

{

 

...

做点什么

...

}

Catch(COleDispatchException& e)

Catch(COleDispatchException& e)

{

}

 

但这不会发现异常。然后我从COleDispatchException&更改参数到COleDispatchException *,如下所示:

But this does not catch the exception. Then I change the parameter from COleDispatchException& to COleDispatchException*, as follows:

 

尝试

{

 

...

做点什么

...

}

Catch(COleDispatchException * e)

Catch(COleDispatchException* e)

{

}

 

然后我将能够捕获异常。所以我只是想知道如何预先知道异常类型,以防止花时间猜测类型?

Then I will be able to catch the exception. So I just wonder how to know the exception type beforehand, to prevent taking time to guess the type?

推荐答案

你好,

哪个函数抛出异常?

问候,Guido


这篇关于如何确定异常类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆