Solved

simple exception handling

Posted on 2004-04-06
12
194 Views
Last Modified: 2013-11-20
hello experts,

i'm very new on exception handling on a PDA, using embedded visual c++ 3.0, I would like to only catch CMemoryExceptions.
how can i do this?
i know it is with
__try{
     code where exception can get thrown
}
__except ... but here i'm stuck. How can i only catch CMemoreException?

thx,
0
Comment
Question by:lolliebollie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
12 Comments
 
LVL 11

Expert Comment

by:KurtVon
ID: 10765861
try
{
  blah blah blah;
}
catch (CMemoryExcpeiton* exception)
{
  blah blah blah;
}

Should do the trick.  A catch block only catches exceptions of the type it specifies (or objects derived from that object).

Hope this helps.
0
 

Author Comment

by:lolliebollie
ID: 10765930
in visual c++ this would work, but it doesn't in embedded visual c++.
embedded visual c++ doesn't suppport  this way of exception handling.
0
 
LVL 11

Expert Comment

by:KurtVon
ID: 10765981
If you must use the try...except clause, you will need to write a filter routine to handle the event.  The try...except only catches terminating events, and under C++ the catch is much more flexible, but there could be reasons why you need the try...except block.

In that case, check out the example at the bottom of this page: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/_langref_try_except_statement.asp

Hope this helps.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Expert Comment

by:KurtVon
ID: 10766007
Oh and a list of teh exceptions you can filter on is here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/minidump_exception_str.asp

Sorry that the catch doesn't work in embedded C++.  Odd that.
0
 
LVL 15

Accepted Solution

by:
lakshman_ce earned 50 total points
ID: 10766028
I think KurtVon's method should work. Embedded Visual C++ supports both C++ Exception handling(KurtVon's code) and structured exception handling (your code)
Plz refer to this for details
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vccelng4/html/elgrfexceptionhandling.asp
and here is the link for the sample code showing C++ exception handling in the embedded VC++ MSDN reference
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vccelng4/html/ellrftrycmacatchcmaandthrowstatements.asp

-Lakshman
0
 

Author Comment

by:lolliebollie
ID: 10766273
thx for the fast replys,

i'll give it a try

and for the try and catch i found that windows CE doesn't support this, and if i try i get the warning
"warning C4531: C++ exception handling not available on Windows CE. Use Structured Exception Handling"

i'll get back to you guys, thx :)
0
 

Author Comment

by:lolliebollie
ID: 10766480
and Lakshman you"re right, in some places u find that evc supports structured exception handling and some other places you find that it doesn't, and also if you try to compile u see a message they don't (^^)

i find it strange
0
 

Author Comment

by:lolliebollie
ID: 10766495
evc 3.0 doesn't support, but evc 4.0 does :)
to bad i have to use 3.0
0
 
LVL 15

Expert Comment

by:lakshman_ce
ID: 10766510
Upgrade to evc 4.0 :-)

-Lakshman
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question