Solved

simple exception handling

Posted on 2004-04-06
12
186 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
 
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Host to IP 7 73
Hibernate methods 2 58
changeXy challenge 13 57
Problem to open Excel file 15 40
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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

706 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

20 Experts available now in Live!

Get 1:1 Help Now