Solved

simple exception handling

Posted on 2004-04-06
12
191 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
Technology Partners: 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.

730 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