[Cppcms-users] cppcms hangs if cppcms::application ctor throws exception
Brought to you by:
artyom-beilis
|
From: Karsten A. <kar...@go...> - 2013-11-29 10:02:26
|
Hi,
cppcms hangs if the constructor of cppcms::application and derived class
throw, see the code below. Any ideas how to fix this?
#include <cppcms/applications_pool.h>
#include <cppcms/service.h>
#include <cppcms/http_response.h>
#include <cppcms/application.h>
#include <iostream>
#include <stdexcept>
using namespace std;
class my_app : public cppcms::application
{
public:
my_app( cppcms::service& srv )
: cppcms::application( srv )
{
throw std::runtime_error( "Exception" );
}
virtual void main(std::string url)
{
cout << "Hello world!" << endl;
response().out() <<
"<html>\n"
"<body>\n"
" <h1>Hello World</h1>\n"
"</body>\n"
"</html>\n";
}
};
int main( int argc , char **argv )
{
try
{
cppcms::service app( argc , argv );
app.applications_pool().mount( cppcms::applications_factory<
my_app >() );
app.run();
}
catch( std::exception const &e )
{
std::cerr << e.what() << std::endl;
}
return 0;
}
|