Solved

simple exception handling

Posted on 2004-04-06
12
189 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
  • 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sum67 challenge 35 97
abstract class with all non abstract mentods 6 76
My project did see openJDK that I installed. What could be the problem 7 140
Detect file exist or not 3 154
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: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

813 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now