
HELP! Whats wrong with this code?VC1.52
Quote:
> So I thought I would try and catch the DBexception. but "try" is now
> allowed in VC1.52 only "TRY" (does this make a difference?), and the
> error when compiled is:
> **** error C2143: syntax error : missing ';' before 'catch' ****
"Chapter 16 Exceptions" of the "Class Library User's Guide"
of the Documentation of VC 1.5 will answer your question.
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
The following instructions and examples will show you how to catch
exceptions.
T To catch exceptions
Use the TRY macro to set up a TRY block. Execute any program statements
that might throw an exception within a TRY block.
Use the CATCH macro to set up a CATCH block. Place exception handling code
in a CATCH block. The code in the CATCH block is executed only if the code
within the TRY block throws an exception of the type specified in the CATCH
statement.
The following skeleton shows how TRY and CATCH blocks are normally
arranged:
// Normal program statements
...
TRY
{
// Execute some code that might throw an exception.
Quote:
}
CATCH( CException, e )
{
// Handle the exception here.
// "e" contains information about the exception
Quote:
}
END_CATCH
// Other normal program statements
...
Note The END_CATCH macro marks the end of the CATCH blocks.
The CATCH macro takes an exception-type parameter, allowing you to
selectively handle different types of exceptions with sequential CATCH and
AND_CATCH blocks as listed below:
TRY
{
// Execute some code that might throw an exception.
Quote:
}
CATCH( CMemoryException, e )
{
// Handle the out-of-memory exception here.
Quote:
}
AND_CATCH( CFileException, e )
{
// Handle the file exceptions here.
Quote:
}
AND_CATCH( CException, e )
{
// Handle all other types of exceptions here.
Quote:
}
END_CATCH