I'm not sure this will fix your problem, but you should always catch by
const reference, not by value. I.e., catch (const CryptoPP::Exception &e).
Catching by value means you're making a copy of the exception object
whenever you catch it.
----- Original Message -----
From: "Brian Roundhill" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, August 10, 2005 7:03 AM
Subject: Catching exceptions
I am having a devil of a time catching Crypto++ exceptions.
I added a wrapper file and compiled the library in Microsoft Visual
Studio. The wrapper file is C function headers to encrypt and decrypt
because one of our products is in C. Everything works fine until something
goes wrong.
Code of the problem area, with two of the catch's I've tried:
std::string szRSA; // This has the RSA private key.
try
{
pbyDecryptedData = RSADecryptString(&szRSA, (char*)byEncryptedData);
}
catch ( CryptoPP::Exception excp)
{
// Handle error
}
catch (...)
{
// Handle error
}
When we have an invalid RSA key, a BERDecodeErr exception is thrown, as
expected. In debug, this is causing a Microsoft C++ Exception, but is
then caught and handled. In release, I get 'Runtime Error!' and 'abnormal
program termination'. I cannot get the catch to catch. I've also tried
std::exception.
I'm sure it's something simple and easy that I'm missing, but could
someone please point it out to me? Many thanks in advance.
--
-----------------
Brian Roundhill
Fiserv EPSIIA
512-329-0081 x232