如何识别异常? [英] How to identify exception ?

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

问题描述

大家好!


是否有可能在catch(...)中识别throw语句?

我可以识别传递给的异常类型catch(...)?

我正在试图找出问题,这可能是库中的某个地方

我正在使用。

这是实时程序,因此逐步调试是非常困难的。

程序是用gcc-3.3编写的,在Linux上运行


最好的问候

Jarek。

解决方案

>大家好!


是否可以在catch(...)中识别throw语句?
我可以识别传递给catch(...)的异常类型吗?
我正在努力找出问题,这可能是我正在使用的库中的某个地方。
这是实时程序,所以逐步调试非常diffcult。
程序是用在Linux上的gcc-3.3编写的

最好的问候
Jarek。




如果全部您可以通过catch(...)来捕获异常,然后您的处理代码应该做的唯一的假设是抛出异常。如果

异常本身是多态的,你知道基本类型那么你可以使用RTTI(例如dynamic_cast,typeid()等)来支持


>
ben


我不推荐这种方法,但是......

如果你明显扔掉那么你可以使用__LINE__和__FILE__

预处理程序指令要么创建对象,要么如果你是
放弃任何理智设置一个全局变量。

如果你这样做这个,然后我在混淆的C ++比赛中获得联合奖励

:)


benben写道:

如果您只能通过catch(...)来捕获异常,那么您的处理代码应该做的唯一假设是抛出异常。如果异常本身是多态的,你知道基类型,那么你可以使用RTTI(例如dynamic_cast,typeid()等)




问题是我对此异常一无所知。我试过了几个catch-es(异常,char *等),但是没有人可以匹配。


是否有一些分析代码来分析代码的工具找到所有的投掷?

在eclipse中为java做点什么?


最好的问候

Jarek


Hi all!

Is it possible to identify throw statement, within catch( ... )?
Can I identify type of exception passed to catch(...) ?
I''m trying to identify problem, which is probably somewhere in library
which I''m using.
This is real-time program, so step-by-step debbuging is very diffcult.
Program is written in gcc-3.3 working on Linux

best regards
Jarek.

解决方案

> Hi all!


Is it possible to identify throw statement, within catch( ... )?
Can I identify type of exception passed to catch(...) ?
I''m trying to identify problem, which is probably somewhere in library
which I''m using.
This is real-time program, so step-by-step debbuging is very diffcult.
Program is written in gcc-3.3 working on Linux

best regards
Jarek.



If all you can do to catch the exception is through catch(...) then the only
assumption your handling code should make is that an exception is thrown. If
the exception itself is polymorphic and you know the base type then you can
use RTTI (e.g. dynamic_cast, typeid(), etc)

ben


I''m not recommending this approach but...
If you explictly throw then you can use the __LINE__ and __FILE__
preprocessor directives either to create an object, or if you are
abandoning any sanity set a global variable.
If you do this, then I wany joint credit in the obfuscated C++ contest
:)


benben wrote:

If all you can do to catch the exception is through catch(...) then the only
assumption your handling code should make is that an exception is thrown. If
the exception itself is polymorphic and you know the base type then you can
use RTTI (e.g. dynamic_cast, typeid(), etc)



The problem is that I don''t know anything about this exception. I tried
few catch-es (exception, char *, etc), but no one can match.

Is there some tool to analyze to analyze code to find all throws ?
Something like in eclipse for java ?

best regards
Jarek


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

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