Re: Shared library throws exception but not caught
On Jan 8, 6:20 pm, "James K. Lowden" <jklow...@speakeasy.net> wrote:
On Mon, 7 Jan 2013 23:27:30 CST
Perhaps the function is returning an error instead?
I am sure that exception is being thrown. I have written the function
to throw the exception. Here is the code snippet from the library:
static bool DataClass::GetEvent(int id) const {
if (myEventType->id != id) {
throw std::logic_error(boost::str(boost::format("No such event
type id (%1%)") % id));
}
else {
return true;
}
}
My catch block in the main program is like:
try {
if(DataClass::GetEvent(Id))
std::cout << "\n ENABLED \n";
else
std::cout << "\n DISABLED \n";
}
catch(std::logic_error& e) {
std::cout<< "\n Exception caught = " << e.what();
}
When I put the catch block inside the library I do catch the
exception, it is only when I put it in the main program (outside the
library), that's when I fail to catch the exception.
Thanks,
Kiran
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]