Valhalla Legends Forums Archive | General Programming | Exception problem

AuthorMessageTime
taylorjonl
This code is driving me nuts...

I am trying to get my error code working good and am simulating an error code. Basically I have a program that loads modules and the particular module I am having an issue with is expecting a file to be available. The file of course isn't available since I am simulating an error. I can't figure out why the below code doesn't function the way I think it should.

First let me paste the output from from program.

[code]Exiting CdKeySpoofer::CdKeySpoofer()
Entering CdKeySpoofer::OnLoad()
Threw exception
Entering LoadModuleFailed::LoadModuleFailed()
Exiting LoadModuleFailed::LoadModuleFailed()
Caught exception in LoadSpyModule()
Exiting Connection::LoadSpyModule()[/code]

Here is the relevent code. The first and last line aren't shown being outputed in code below but included so show context.

[code] if(!spy)
{
UNLOCK_MUTEX(m_mSpyModuleList);
throw ModuleCreationFailed(module);
}

try
{
try
{
// call OnLoad() for module
if(!spy->OnLoad())
{
throw SpyModuleException(module, "OnLoad() returned false");
}
}
catch(...)
{
printf("Threw exception\n");

// UNLOCK_MUTEX(m_mSpyModuleList); // I want this uncommented
// throw SpyModuleException(module, "OnLoad() returned false");
throw LoadModuleFailed(module);
}

// insert in module list
m_SpyModuleList.push_front(spy);

}
catch(LoadModuleFailed& e)
{
printf("EXCEPTION: %s\n", e.String());
}
catch(...)
{
printf("Caught exception in LoadSpyModule()\n");
}[/code]

My understanding of the code is that the first catch block should catch the exception according to the output. I have been analyzing this code for quite some time trying to find an error but it seems fine to me.

Help me.
February 15, 2004, 5:40 AM

Search