www.digitalmars.com         C & C++   DMDScript  

c++.chat - Question on try catch semantics:

reply Nicholas Jordan <Nicholas_member pathlink.com> writes:
Question on try catch semantics:

L:\itc\exe\itc.EXE built
Lines Processed: 209987  Errors: 0  Warnings: 1
Successful build

given code snippet:

try
{
length_ = ::_inline_strlen(const_cast<char* const >(in_));
}
catch(int cause_)
{
switch(cause_)
{
default:   break;// stubb
case 0x00: break;// stubb
case 0x01: break;// stubb
case 0x02: break;// stubb
.............and so on...

So what exactly does this catch ???

should this be  catch(int& cause_) // ???

I am tring to intercept the states listied in:
Section 5-2 :: Table 5-1 of the Intel
"Pentium Pro Family Developer's Manual"
[ Volume 3: Operating System Writer's Manual ]

In paticualar:
'Interrupt 13-General Protection Exception(#GP)'
'Interrupt 14-Page Fault Exception(#PF)'

so that I can make a trace-log or recover gracefully.

If I cannot handle the Fault, do I throw(???...);

And throw what, an int ?

- or just exit(-1) )

Most of the texts I have seen say to catch an
exception object - but the only thing I can figure
out is that this is a class one wrote or exception from
STL ~ What is the basic nature of an exception from the 
OS point of view.....
Mar 07 2006
parent reply Heinz Saathoff <newshsaat arcor.de> writes:
Nicholas Jordan schrieb...
 Most of the texts I have seen say to catch an
 exception object - but the only thing I can figure
 out is that this is a class one wrote or exception from
 STL ~ What is the basic nature of an exception from the 
 OS point of view.....
C++ exceptions are different from OS exceptions. C++ exceptions are thrown in normal excecution of the program. When a C++ exception is thrown the programmer has dicided to do so at that point of excecution. OS exceptions are different as they happen when something happens during excecution that is not allowed, e.g. accessing a NULL-pointer or pointer to unallocated memory (your 'General Protection Error'). MS-Windows also has so called 'structured exceptions', but I don't have experiences with them. - Heinz
Mar 08 2006
parent Nicholas Jordan <Nicholas_member pathlink.com> writes:
In article <MPG.1e78ae3deb1abc7c9896fd news.digitalmars.com>, Heinz Saathoff
says...
Nicholas Jordan schrieb...
 Most of the texts I have seen say to catch an
 exception object - but the only thing I can figure
 out is that this is a class one wrote or exception from
 STL ~ What is the basic nature of an exception from the 
 OS point of view.....
C++ exceptions are different from OS exceptions. C++ exceptions are thrown in normal excecution of the program. When a C++ exception is thrown the programmer has decided to do so at that point\. OS exceptions are different as they happen when something happens during excecution that is not allowed, e.g. accessing a NULL-pointer or pointer to unallocated memory (your 'General Protection Error'). MS-Windows also has so called 'structured exceptions', but I don't have experiences with them. - Heinz
Correct, and generally the programming of an operating system is tied to hardware and best left to engineers cross-trained in cs and E.E. ,.... Problem is, I live in the real-world: I have had *numerous* instances which prove beyond any shadow of reason or stretch of the imagination that the ... [as discussed in Scott Meyers "Effective STL", Introduction] Right now, in my inbox - every one of these is crap: 11 Joshua Smith Don't be inadequate anymore! 07 Mar 2003 6K 9 Ryan Stewart Hey baby, found this site and wanted you to... 8 Bryson Foster Need S0ftware? 06 Mar 2006 12K 7 Victor Morris CIAli$ mail for you! 06 Mar 2006 6K 6 Lance Campbell Buy OEM Software 06 Mar 2006 12K 4 Alejandro Rivera 0EM Software 01 Mar 2006 12K 2 Logan Moore The Industries leading enhancement product,... 'structured exceptions' - I believe is/are where one sets up an exception object before anything goes wrong, the calls it if needed...... The above crap is no exception and has to be trapped by me long enough to make a trace log or someone else will burn me to Smithereens. Mr. Meyers has a Phd and is therefore constrained to professional language. Example: I just had a discussion with my branch manager of my bank and *somebody*'s gonna get their butt fried by the president of the bank. When going in the real world, there are risks involved that *cannot* be left to chance and millisecond responses matter. All I did that got me "CIAli$ mail for me" is try to use the computer in the routine use of the computer for it's intended purpose.. I know we cannot trap page-faults, .... and all manner of discussion and coding experience await me - but you do not go on an accounting trail singing 'Oh, oh - I lost ten thousand dollars - let me order more software !' I would like to keep this alive till someone with the training and knowledge suggests methods and approaches.
Nicholas Jordan schrieb...
Mar 11 2006