Exceptions

N

Nils

Hi,
sometime the following line produces an exception:
((CMessageDialog*)vec->at(0))->EndDialog(1);
Now I want to catch this Exception, tried it with c++ and mfc exception
handling, like:
C++ in MFC

try
{
((CMessageDialog*)vec->at(0))->EndDialog(1);
}
catch(CException *e)
{

}
---------------------------------------------------------
MFC Makro
TRY
{
((CMessageDialog*)vec->at(0))->EndDialog(1);
}
CATCH(CNotSupportedException, pEx)
{
}
END_CATCH
The Debugger still shows exceptions but never enters the chatch area.....

Can anyone please help me, why the exception is not catched?

Thank you
 
H

Hendrik Schober

Nils said:
Hi,
sometime the following line produces an exception:
((CMessageDialog*)vec->at(0))->EndDialog(1);
Now I want to catch this Exception [...]


The question would be: What of this line
produces the exception?
From what I see it could either be 'at()'
or 'EndDialog()'. If it's the formerm a
'catch(const std::exception&)' would catch
it.
[...]
Thank you

Schobi

--
(e-mail address removed) is never read
I'm Schobi at suespammers dot org

"Sometimes compilers are so much more reasonable than people."
Scott Meyers
 
N

Nils

Hi,
the 0. position is a pointer to an Dialog. I think two threads try to acces
the dialog... So it is an Accessexception, the id is 0xc0000005.
But the exception is not chaught.

in german:
Hi,
Du sprichst deutsch oder? :=)
Also ich an der 0.ten Position befindet sich ein Zeiger auf einen Dialog...
Die Exception ist eine Zugriffsexception weil 2 Threads auf den Dialog
zugreifen. Der Dialog sollte synchronisiert und gelockt sein..
Aber ich kann den Exception nciht abfangen...
In MFC sind doch alle Exception von CException abgeleitet, oder?


Hendrik Schober said:
Nils said:
Hi,
sometime the following line produces an exception:
((CMessageDialog*)vec->at(0))->EndDialog(1);
Now I want to catch this Exception [...]


The question would be: What of this line
produces the exception?
From what I see it could either be 'at()'
or 'EndDialog()'. If it's the formerm a
'catch(const std::exception&)' would catch
it.
[...]
Thank you

Schobi

--
(e-mail address removed) is never read
I'm Schobi at suespammers dot org

"Sometimes compilers are so much more reasonable than people."
Scott Meyers
 
H

Hendrik Schober

Nils said:
Hi,
the 0. position is a pointer to an Dialog. I think two threads try to acces
the dialog... So it is an Accessexception, the id is 0xc0000005.
But the exception is not chaught.

Access violations shouldn't be caught,
they should be fixed. They represent
an error in your program. You don't
want to hide that error. You want it
to be seen so it gets fixed.
That said, if you really want to catch
it, Structured Exception Handling is
what you need.
in german:
Hi,
Du sprichst deutsch oder? :=)
Also ich an der 0.ten Position befindet sich ein Zeiger auf einen Dialog...
Die Exception ist eine Zugriffsexception weil 2 Threads auf den Dialog
zugreifen. Der Dialog sollte synchronisiert und gelockt sein..

Gut. Und wenn das getan wurde, gibt es
hoffentlich keine AV mehr. Warum willst
Du sie fangen?
Aber ich kann den Exception nciht abfangen...

Suche SEH in der MSDN Lib. Oder laß es
lieber, und behebe den Fehler.
In MFC sind doch alle Exception von CException abgeleitet, oder?

Ich habe MFC nie benutzt.


Schobi

--
(e-mail address removed) is never read
I'm Schobi at suespammers dot org

"Sometimes compilers are so much more reasonable than people."
Scott Meyers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top