Home > Back-end >  C exception handling problems
C exception handling problems

Time:09-24

Void ComPort: : Close ()
{
Try
{
If (m_file m_hFile!=INVALID_HANDLE_VALUE)
M_file. Close ();
}
The catch (CFileException * e)
{
TCHAR strCause [256].
E - & gt; GetErrorMessage (strCause, 256);
E - & gt; The Delete ();

Throw ComPortException (strCause);
}

M_hPort=NULL;
}


The great god, how can enter the catch?

The catch is not through throw into? But throw in the catch

CodePudding user response:

Some function within throws an exception,

CodePudding user response:

Certain exceptions are programmers manual throw them, some is c + + runtime capture after throw (null Pointers, an array of floating point error, etc.),

When you use the try 'monitoring' this code, if any abnormal happen will enter your default catch the exception handling exception type matching, once the match is this exception handling code, how to deal with it is your own things, such as the above code you can simply record the exception type, and throw the exception again to the a layer of calling a function on the processing,
  • Related