如何处理该异常 [英] how to handle that exception

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

问题描述


我是新手,正在尝试将代码添加到C ++/CLI代码中.

问题是有一个线程,它在一定条件下运行良好,它先调用一个例程,然后该例程调用另一个例程.
回到线程后,会发生异常.

我有个尝试{}赶上{}

我该如何解决?
如何知道发生了什么异常?

谢谢
Eman

Hi
I am a newbie trying to add code to a c++/CLI code.

The problem is there is a thread and it runs fine at a certain condition it calls a routine then the routine calls another routine.
After it goes back to the thread an exception happens.

I have a try{} catch{}

How can I fix it?
How to know which exception is happening?

Thanks
Eman

推荐答案

似乎您对异常的工作原理一无所知.只需了解一下-这并非易事.提示:异常是在整个堆栈上工作的(每个踏板单独地,出于原因),并跳过堆栈而忽略了调用和返回的历史记录而到达试验点.这是堆栈的时间机器.

http://en.wikipedia.org/wiki/Structured_exception_handling [
It looks like you have no clue on how exceptions work. Just learn about it — it''s not trivial. A hint: exception is something which works on a whole stacks (of each tread separately, of cause) and jumps over the stack to the trial point ignoring the history of calls and returns. This is a time machine of stack.

http://en.wikipedia.org/wiki/Structured_exception_handling[^].

—SA


您已经在此处发布了此问题 [ ^ ].请仅在一个论坛中发布.
You already posted this question here[^]. Please post in one forum only.


当您添加像这样的简单try-catch时

When you add a simple try-catch like this

try {
}
catch(...) {
}



您可以忽略异常,而只想捕获异常并执行某些操作即可.但是,如果您关心异常,则必须显式命名要处理的异常的类型.它可以按值,按引用,按指针(实际上是按值),或者在C ++/CLI中按句柄(帽子).



you ignore the exception, you just want to catch whatever it is and do something. But if you care about the exception, then you have to explicitly name the type of the exception you want to handle. It can be by value, by reference, by pointer (which is actually by value) or, in C++/CLI by handle (hat).

try {
}
catch(MyException& e1) {
}
catch(std::exception& e2) {
}
catch(ManagedException^ e3) {
}
catch(...) // if none of the above
{
}


以下是一些适合您的链接:
C ++/CLI中的异常 [尝试,捕获和抛出语句 [ ^ ]


Here are some links for you:
Exceptions in C++/CLI[^]
The try, catch, and throw Statements[^]


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

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